Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a CentOS server (rel6) that had python installed (2.6), but I needed a few features in 3.3+. I installed 3.3 into a seperate folder and made a symbolic link to execute it:

  1. I installed setup tools: yum install python-setuptools
  2. I installed a needed module"pandas" easy_install pandas
  3. I executed my pyton script, which encountered an error that required i use a newer version
  4. I downloaded and installed Python 3.3.5 to it's own folder so as to not override my default python
  5. Made s symbolic link to allow me to execute this new python:
    • ln -s /opt/python3.3/bin/python3.3 ~/bin/py

The problem is that when I execute the python script with my new py alias, it does not have all the addons needed (explicitly MySQLdb) which the default install does.

How do i go about installing the MySQLdb module, or any for that matter, to be reachable or useable for the new Python 3.3.5 installation? Or is there a way to make the current modules in 2.6 available to 3.3.5 as well?


My virtual environment has the following installed

root@server [/]# source ./root/python3.3/bin/activate
(python3.3)root@server [/]#
(python3.3)root@server [/]# pip freeze

But when I execute the import, it still fails

(python3.3)root@server [/]# python3.3 -c "import MySQLdb"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'MySQLdb'
share|improve this question

3 Answers 3

For multiple python versions, use virtualenv and pip to manage modules.

So you can create a virtual environment with a specific python versions and modules.

easy_install pip
pip install virtualenv virtualenvwrapper 

So when creating a new environment with a specific python version

mkvirtualenv nameit -p python3.3

If any dependencies python would have, just do this:

wget --no-check-certificate

Extract the files from the archive and get into its path:

tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2

And then install using:

python3.3 install

You can do this last step to install modules on this python version you have, just downloading it and running python3.3.5 setup install, but I recommend you to use virtualenv cause its easy mode of managing different python versions and its modules.

To properly install virtualenv without much trouble, follow these steps

share|improve this answer
I already had easy-install and pip ... so i ran the install for virtualenv and virtualenvwrapper. I don't know much about them but the mkvirtualenv command didnt work. I will try to research more... – Silvertiger Jun 6 '14 at 19:44
alright .. i ws able to activate the environment, and afterward installed setuptools, but the python3.3 still bombs out with "ImportError: No module named 'MySQLdb'" - is MySQLdb part of setuptools? if so, how can i validate that it's actually within the environment i have created? – Silvertiger Jun 6 '14 at 20:14
After you create the environment, you can install theodules specifically by typing 'workon yourenv', and then try 'pip install mysqldb'. Pip will become your modules manager. Oh and you can find out which modules are currently installed for this venv using the command 'pip freeze' – Shu Hikari Jun 6 '14 at 20:33
"workon pythin3.3" says "-bash: workon: command not found". I will "actiavte" my python3.3 environment and see if I can pip install the modules and see if they work as expected. – Silvertiger Jun 7 '14 at 6:05
I activate my environment which i can tell by the propmt "(python3.3)root@server [folder]". Under my environment I see with pip freeze that it has "pandas=0.14.0", "MySQLdb=1.2.5" .. but when I enter python and try "import MySQLdb" or "import pandas" they both result in something like "ImportError: No module named 'MySQLdb'" – Silvertiger Jun 7 '14 at 6:55

I'm not sure about earlier versions but with CentOS 6.5 you can install the CentOS Software Collections Library repo. This gives you access to newer versions of some tools and python 3.3 is one of them.

You can find general information on the SCL here.

You can install the SCL repo with

yum install centos-release-SCL

Then you can install python 3.3 with

yum install python33

The documentation for SCL's is here.

share|improve this answer
Will this supercede my current python 2.6? or will it run concurrently, and will it have full access to the mods that the current 2.6 does? – Silvertiger Jun 6 '14 at 16:08
No, yes, I don't know. Why don't you suck it and see, it's bound to be better than rolling your own. – Iain Jun 6 '14 at 16:30
This installed the SCL - but the modules still were't available to python 3.3. I amworking to implement the virtualend below. – Silvertiger Jun 7 '14 at 6:58
up vote 2 down vote accepted


To solve this issue I created a fresh virtualenv with a specified python (python 3.3), and used the correct installer (easy_install-3.3 which is apparently specific to that python version) to add the modules. As verified by the correction version of pip (pip3.3) it appears to be working now

root@server [~] easy_install pip
root@server [~] pip install virtualenv virtualenvwrapper 
root@server [~] virtualenv --python=/usr/local/bin/python3.3 py3
root@server [~] . /root/py3/bin/activate
(py3)root@server [~] easy_install-3.3 numpy
(py3)root@server [~] easy_install-3.3 scipy
(py3)root@server [~] easy_install-3.3 pandas
(py3)root@server [~] easy_install-3.3 scikit-learn
(py3)root@server [~] easy_install-3.3 PyMySQL

(py3)root@server [~]# pip3.3 freeze

My script now runs as hoped within my virtual environment.

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.