During the past years, I have installed many Python libraries with various Python versions. To make them ready to work immediately, I installed them blindly without control. Currently they're causing problems when I tried to install pynest which invokes numpy, scipy and matplotlib. After struggling, I am going to clean and reinstall Python and the libraries.
After investigation, I found Python 2.5/2.6/2.7/3.2 on my system, and each of them has some copies or other things at: (my OS == Mac OS X 10.7.5 Lion)
/Library/Frameworks/
/opt/local/Library/Frameworks/
/opt/local/bin/
/Applications/
/usr/local/bin/
/usr/bin/
/System/Library/Frameworks/
/System/Libarary/Frameworks
/System/Library/
which python
/usr/bin/python
/System/Library/Frameworks
$PATH
/opt/local/bin:/opt/local/sbin:/opt/nest/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/texbin:/Library/Frameworks/Python.framework/Versions/3.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/django/bin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin:/usr/local/lib/python2.7/site-packages:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.2/bin
easy_install
macports
homebrew
fink
pip
.dmg
.pkg
There're a couples of different way to install Python, as the update of OP says, and they locate files in different locations. For example, macports
puts things into /opt/local/
, while homebrew
puts things into /usr/local/
. Also, Mac OS X brings a few python versions with itself. So, if you install python many times via different ways, you will get many python versions existing independently on your system.
I don't know exactly. I guess the problem is that if you have many versions of python, then which one to use and where to find packages will be determined by the path order in your system PATH
and the PYTHONPATH
respectively. So you may lose control of where to install python modules. Consider that if you run sudo python setup.py install
to install a module (it finds python by the root's PATH
) and then try to import
the module by python -c "import it"
(this time it finds python by your PATH
), maybe something will go wrong. This is my guess, I didn't validate it. But in my own case, something did go wrong.
I think the principle would be that be aware of that different ways and tools install things independently to different locations, so use them mindfully.
virtualenv
)PATH
and consider if it's
correct. Since it had been messing up already and seemed to be very hard to cure, so finally I solved this question by a full OS re-installation, and started to follow the DOs-and-DONTs above. For the installation of the scientific environment with python (numpy/scipy/matplotlib, which had shown problems to make me ask this question), I found this tutorial was extremely helpful. So, problem solved finally.