Python Package Management

15 February 2014

Python had package management long before Visual Studio got Nuget. However, the official Python installation does not actually come with a package manager installed. There are more than one from which to choose, and (as with most things) they all have their strengths and weaknesses. I am pretty new to Python, so I am still learning this ecosystem, but so far this is what I have found.

easy_install

The first package manager I came across was easy_install. I ran into a lot of troubles with it. So, I am a little biased against it now. But, in hindsight, this may have been related to scientific and data analysis packages (see conda below). That being said, there seems to be a lot of reasons not to use it.

pip

More recently I found pip. So far, it seems less troublesome to me than easy_install, but there are still issues (keep reading). On windows, the easiest way to install pip is with Chocolatey. Once Chocolatey is installed, you simply run the following from command line.

cinst pip

Once pip is installed, packages are simple to install via the command line...

pip install [package name]

Conda

At least on Windows 7 x64, pip seems to have a lot of trouble installing scientific and data analysis packages (e.g. NumPy, SciPy, and pandas). According to this and this, installing "extension modules can be an issue with pip." Since these packages are the main reason for my interest in Python, it was important to me to find a solution to this problem. Conda can handle these packages.

Conda comes as part of the Anaconda distribution of Python. It can be installed with minimal dependencies via Miniconda, but I opted to uninstall the official Python distribution and install Anaconda distribution.

Since I already had tools installed, I had to manually fix my PYTHONHOME environment variable and restart. Also, since I already had PyCharm installed, I had to change its settings to point to the new interpreter. But, after fixing these issues, Conda worked like a charm to install pandas.

In the end, I later had a problem installing PyMongo with Conda and had to fall back to pip for that. I suspect that there is some way to configure Conda to handle this. But, at this time, it is not worth my trouble.

Conclusions

If you are interested in data analysis packages, start off by using Anaconda and installing packages via Conda. If Conda cannot find a package that you are interested in, use pip.

However, if you are not interested in data analysis packages, pip seems to work just fine.