Okay I recently upgraded from Ubuntu 10.04 to 12.04
Only to be faced by a lot of problems. I am a newbie at this so you might have to tell me in a little more detail or
Using virtualenv
First things first. Make sure you have Mysql, Setuptools and some essentials:
sudo apt-get install mysql-server
sudo apt-get install python-setuptools python-dev build-essential
Now install VirtualEnv:
sudo easy_install -U virtualenv
Create a Virtual Environment. As the documentation says: virtualenv is a tool to create isolated Python environments.
This means that the chances of getting a conflict are really small. Here "myenv" is the name of a folder where you can access your environment, so create it where you want.
virtualenv --distribute myenv
Then go to "myenv" directory and run this to activate it:
source myenv/bin/activate
You need to install libmysqlclient-dev to get MySQL-python working:
sudo apt-get install libmysqlclient-dev
Now you're ready to install MySQL-python:
pip install MySQL-python
and everything should be working.
When you don't want to work in that environment anymore, write in the terminal:
deactivate
UPDATE:
Since this answer keeps getting upvotes, let me show you how to do the same using conda, which has become my favorite environment nowadays. First you have to install anaconda (I believe you can also install miniconda, which is a lighter version that includes conda and some packages.) Here you will find the installer for Linux, OS X and Windows. It is a big file but contains a lot of pre-compiled packages ready to be installed. Assuming you already have installed anaconda, you can simply run:
conda create -n mysql-env python
mysql-env
is the name of the environment (you can call it whatever you want) and python
is the default version of python to be installed (currently, 2.7.10). Alternatively, install other version of python with conda create -n my-new-env python=3.4
.
Then you activate your environment:
source activate mysql-env
and finally install mysql-python:
conda install MySQL-python
(I think conda install mysql-python
also works)
And that's all.