سؤال

I wanted some numeric modules of python. I installed canopy from enthought that is supposed to have all the necessary modules I need. e.g.: matplotlib.pyplot and scipy. After installation, I tried to import the module, I get the following error. I have python2.7 running in my mac OS X. should I have to change my pythonPath or something to have this work, I searched around the web, but could not find a clear answer.

import matplotlib.pyplot as plt
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib.pyplot
import scipy
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named scipy

Thanks

هل كانت مفيدة؟

المحلول

If you don't choose at installation to make Canopy your default python, you will need to add its executable on the path if you want it to be invoked when you start python or ipython as opposed to your system python. The python executable in Canopy should be at ~/Library/Enthought/Canopy_**bit/User/bin/python where ** is 32 or 64 depending on the architecture you chose.

You can modify your .bash_profile and add ~/Library/Enthought/Canopy_**bit/User/bin/ first on your PATH or run the following from your terminal:

source ~/Library/Enthought/Canopy_**bit/User/bin/activate

for this to be true until you close your terminal.

HTH,

نصائح أخرى

Most likely: either

1) As @jonathanrocher suggested you are running the wrong Python (see https://support.enthought.com/entries/23646538-Make-Canopy-User-Python-be-your-default-Python). One way to make this mistake is if you ran the python that you found in /Applications. Do not do that! Instead, you should run the Canopy that you find in /Applications, and it will set up your User Python for you and give you the chance to make it your default Python.

or 2) or you are getting interference from your pre-existing PYTHONHOME or PYTHONPATH environment variables (see the warning at the top of https://support.enthought.com/entries/23665767-How-do-I-set-PYTHONPATH-and-other-environment-variables-for-Canopy).

To explicitly answer your question -- no, you should have no PYTHONPATH set.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top