Best practice for upgrading Python modules
Asked Answered
M

1

7

I've been learning Python for several months but now finding some problems with my 2.7 installation as I've looked into modules such as nltk.

However, when I want to list modules using help ("modules) I have the main error which I think explains the problem is:

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/command/install_scripts.py:3: UserWarning: Module numpy was already imported from /Library/Python/2.7/site-packages/numpy-override/numpy/__init__.pyc, but /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg is being added to sys.path
from pkg_resources import Distribution, PathMetadata, ensure_directory

I also receive the following error to do with deprecated modules:

    /Library/Python/2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-intel.egg/scikits/statsmodels/__init__.py:2: UserWarning: scikits.statsmodels namespace is deprecated and will be removed in 0.5, please use statsmodels instead

I'm still trying to get to grips with paths. How can I avoid this issue in future?

Maize answered 9/10, 2012 at 7:24 Comment(0)
W
6

You have installed packages under your operating system Python library. This is big no no. What you should have done is to create an isolated, disposable, Python environment with virtualenv tool:

http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of-python-software-with-virtualenv/

This way, when you upgrade your packages or need to get rid of them you can always reset the state of all of your Python packages by simply deleting the environment and creating new one.

Python packages installed via pip or easy_install commands are easy to install, but impossible to uninstall...

But when the damage has already happened you nede to manually try to clean up /Library/Python/2.7/site-packages/ by deleting files by and trying not to destroy your system Python in the process.

Waverley answered 9/10, 2012 at 8:20 Comment(2)
Thank you for that. Sounds like I'm going to have some fun, then. That will teach me to hack around without some clear understanding of what I'm doing.Maize
It's not exactly your fault: there is plenty of bad examples out there in the internet telling you do "sudo easy_install". It will solve your problem in short term, just to bite off your leg later.Waverley

© 2022 - 2024 — McMap. All rights reserved.