Python Forum
Path to python, matplotlib, scipy, numpy, etc. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Path to python, matplotlib, scipy, numpy, etc. (/thread-25357.html)



Path to python, matplotlib, scipy, numpy, etc. - dcollett - Mar-28-2020



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




RE: Path to python, matplotlib, scipy, numpy, etc. - ndc85430 - Mar-28-2020

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.


RE: Path to python, matplotlib, scipy, numpy, etc. - dcollett - Mar-28-2020

Hi, ndc85430. Thanks for your help. Yes, IDLE is the most current version that came with Python 3.8.


RE: Path to python, matplotlib, scipy, numpy, etc. - ndc85430 - Mar-29-2020

What is the value of sys.path in IDLE? Post the value please.


RE: Path to python, matplotlib, scipy, numpy, etc. - dcollett - Mar-29-2020

Hi, ndc85430. Thanks for helping.

In IDLE, where do I find sys.path?

Thanks.


RE: Path to python, matplotlib, scipy, numpy, etc. - ndc85430 - Mar-29-2020

Look at your first post - do exactly the same.


RE: Path to python, matplotlib, scipy, numpy, etc. - dcollett - Mar-29-2020

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']
>>>