Python Forum
Path to python, matplotlib, scipy, numpy, etc.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Path to python, matplotlib, scipy, numpy, etc.
#1


Hi, everyone. I hope some of you can help me.

I'm running Python 3.8.2 on a Mac. I installed numpy, scipy, and matplotlib using pip.

From the command line (in Terminal), if I type % Python3 then >>> import matplotlib, it works. (same for scipy and numpy)

But in IDLE, I get this error:
ModuleNotFoundError: No module named 'matplotlib'
(same for scipy and numpy)

Obviously, IDLE doesn't know where to look. I've looked at many articles about .profile, and PATH, but I don't know what to do.

Currently, in my /Users/david folder is .profile which contains only 1 line (which I created because there wasn't a .profile there):

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Is this what should be there?

One article I read said to type this in Python:

>>> import sys
>>> sys.path


The output of that was:

['', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']

Are one of these the paths I need in .profile?

I realize that this is probably a basic question, but obviously I'm lost.

I'll appreciate any help you can offer. Thanks!

David

Reply
#2
No, the PATH environment variable is for executables and has nothing to do with where Python looks for libraries.

Are you sure that IDLE is for the same version of Python as on the command line? Perhaps you have two versions of Python installed.
Reply
#3
Hi, ndc85430. Thanks for your help. Yes, IDLE is the most current version that came with Python 3.8.
Reply
#4
What is the value of sys.path in IDLE? Post the value please.
Reply
#5
Hi, ndc85430. Thanks for helping.

In IDLE, where do I find sys.path?

Thanks.
Reply
#6
Look at your first post - do exactly the same.
Reply
#7
Thanks again for helping. I think from trying so many things (and probably having too many versions of Python(?) on my system), the OS was messed up.

So, I did Recovery and reinstalled Mac OS. "Magically," everything now works as it should. I'm not touching a thing.

However, just to make sure, here is sys.path – does this look correct? Thanks again for your help!

>>> import sys
>>> sys.path
['', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Users/david/Library/Python/3.8/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']
>>>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,203 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,220 Mar-11-2021, 10:52 AM
Last Post: buran
  ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package AaronKR 1 10,238 Jul-09-2020, 02:36 AM
Last Post: bowlofred
  Python scipy odeint: solving with solution-dependent functions etienne 0 2,739 Jun-05-2020, 01:29 PM
Last Post: etienne
  How to plot implicit functions (with two variables) in scipy python using matplotlib? Jay_Nerella 1 7,931 May-11-2019, 01:17 AM
Last Post: scidam
  Relations between python 2.7 3 3.7, scipy, pip? larkypython 2 2,427 May-05-2019, 06:43 AM
Last Post: Gribouillis
  Problem installing numpy and matplotlib achondrite 1 3,117 Jan-16-2019, 11:43 PM
Last Post: snippsat
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,740 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020