Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for upgrading Python modules

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?

like image 641
elksie5000 Avatar asked Oct 09 '12 07:10

elksie5000


People also ask

Should I always update Python?

But more directly at your question; if the library has a security bug, you really should update. This is rare across all python modules (in the sense that most don't have a security concern to begin with). Beyond that, updating gives you new features and bug fixes.


1 Answers

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.

like image 114
Mikko Ohtamaa Avatar answered Sep 27 '22 18:09

Mikko Ohtamaa