While trying to build my python by adding numpy to it I managed to have created problems somewhere. Now, even though I have numpy and other packages like Beautiful开发者_如何学编程Soup installed, I'm unable to import them from within my mac's default python. Previously I was able to import them.
Where should I initially look for potential problems? My bash profile? .profile? Somewhere in python? Any help would be appreciated. I'm very new to installing packages as well as path variables so any guidance as to where the error might be would be helpful.
EDIT
After following John Keyes' advice and printing python's path this was the result:
['','/Library/Python/2.7/site-packages/pip-1.0.2-py2.7.egg',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Library/Python/2.7/site-packages',
'/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Should these paths include my installed packages (such as numpy and beautiful soup) listed?
EDIT 2
This is my bash profile. From the comments on my question it seems like these may be the issue, so I thought I'd include them below. How can I change them so that my python build will go back to installing things in the right place?
export PATH=/usr/local/bin:/usr/local/share/python:/usr/local/sbin:$PATH
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
As I understand you have build a custom python which is not same with your default python installation.
You should either use the newly installed python or specify the path of numpy to the default installation. There are 2 ways of doing the second choice:
Asume that your numpy module is located at /Users/Me/python/modules directory.
Set an environment variable for external modules from commandline:
setenv PYTHONPATH /Users/Me/python/modules
To make this permanent for your user you could add this line to your .bashrc file.
In your code you could add the same directory to your path:
import sys sys.path.append('/Users/Me/python/modules') import numpy ...
I hope this will help.
精彩评论