Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What is the best way to install python packages in Ubuntu 11? I am a recent convert to Ubuntu and want to learn best practices.

For context, I am looking to install the tweeststream package, but I did not see it in my Synaptic package manager. Also, I am very new to programming but usually can follow along with code samples.

share|improve this question

4 Answers 4

up vote 11 down vote accepted

I think best way for you would be to install Python packaging system like "python-pip". You can install it with Synaptic or Ubuntu Software Center.

Pip will allow you to easy install and uninstall Python packages, simply as pip install package

In your case it would be something like this from terminal:

sudo pip install tweeststream

share|improve this answer
This is fine for simple packages, but not so good for larger packages e.g. numpy –  hayd Oct 25 '13 at 18:03

In addition to Novarchibald's addition, it is generally a good idea to create a virtual environment for your python project and install dependencies inside. This allows you to have better control over dependencies and their versions. To set up a virtual environment, enter:

virtualenv --no-site-packages --distribute my_python_project

Then, activate it with:

cd my_python_project
source bin/activate

At this point anything that you install with pip will be kept inside this virtual environment. If you want to install something globally, then you should first exit virtualenv with:


You can find out more about virtualenv here.

share|improve this answer
Alternatively: using the pip from the virtualenv bin directory (here my_python_project/bin/pip) you maintain that environment, without a need to "activate" it. Then - using any of scripts installed in the bin is using given virutalenv. "activate" is only handy to make calls to "python", "easy_install" and "pip" using virtualenv specific bin. –  Jan Vlcinsky Jun 17 '13 at 11:54
Python's install docs say to use "pyvenv" to create virtual environments specific to a project; but that virtualenv is a fall back for projects using older python version, docs.python.org/3/installing/index.html?highlight=pip. –  pbhj Nov 25 '14 at 1:03

This is somewhat a duplicate of easy_install/pip or apt-get.

I think it depends on the package you want to install. If it is mainly Python code, compiled by your Python interpreter, then pip is very good, especially if you need the latest version, or the module is not in the Ubuntu repository. Pip is definitely preferred over easy-install from distribute, from PEAK's setuptools or setup.py, because it will always wait until the package is completely downloaded and built before it copies it into your file system, and it makes upgrading or uninstalling a breeze. In a lot of ways it is similar to apt-get, in that it generally handles dependencies well. Also, I second Wojciech's suggestion to use virtualenv.

Read Installing Python Modules in the Python documentation and Get Packages on the Python Package Index main page.

However, as a rule, I tend to prefer using either the Ubuntu Software Center, apt-get install or synaptic. The main reason being that this will install packages from the Ubuntu repository, which will build and install all of the necessary dependencies in the correct locations, it will know where to look for the tools needed to build them (make, libgcc, etc.) and to run them (Qt, GNOME). This is especially important for packages with lots of binaries that need to be compiled during an installation. Python numpy & scipy are perfect examples. Try to install these with pip, and you will see an endless stream of compile errors. However, installing numpy & scipy through the Ubuntu repository is as easy as...

$ sudo apt-get install python-numpy python-scipy

You are in luck, because you are using Ubuntu, one of the most widely supported and oft updated distributions existing. Most likely every Python package you will need is in the Ubuntu repository, and probably already installed on your machine. And every 6 months, a new cycle of packages will be released with the latest distribution of Ubuntu.

share|improve this answer

In addition to Zetah'a answer, command to install python-pip from terminal is:

sudo apt-get install python-pip
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.