PDA

View Full Version : Issues installing mysqldb-python



DarkByte
12-07-2012, 05:18 AM
I am trying to install mysqldb-python onto a centos vps server via ssh terminal. Heres what im doing:


easy_install mysql-python

Now when i run python from terminal:
Last login: Thu Dec 6 14:23:54 2012 from -----------
[Only registered and activated users can see links]
Python 2.7.2 (default, Oct 30 2012, 15:05:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
>>>


What I think the problem may be:

When I run "python scriptname.py" python 2.4 loads by default , So I use "python2.7 scriptname.py" the package manager in plesk does not allow me to uninstall the default python as Centos uses it.


So I tried the above test with just the standard python installation:

[Only registered and activated users can see links]
Python 2.4.3 (#1, Jun 18 2012, 08:55:23)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>


This works! So my easyinstall is installing the script for the wrong python is there any easy solution to this?

Zachafer
12-07-2012, 05:37 AM
Make sure you have python-dev installed.

This should work otherwise: [Only registered and activated users can see links]

DarkByte
12-07-2012, 07:05 AM
Thanks with a little more digging with the info you posted I got it!


/root$ sh setuptools-0.6c11-py2.7.egg
Processing setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin

Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
/root$ easy_install mysql-python
Searching for mysql-python
Reading [Only registered and activated users can see links]
Reading [Only registered and activated users can see links]
Reading [Only registered and activated users can see links]
Best match: MySQL-python 1.2.4c1
Downloading [Only registered and activated users can see links]
Downloading [Only registered and activated users can see links]=a05925412cd824104da064db6a889613
Processing MySQL-python-1.2.4c1.zip
Running MySQL-python-1.2.4c1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dxDCyG/MySQL-python-1.2.4c1/egg-dist-tmp-ZGj_rN
Extracting in /tmp/easy_install-dxDCyG/MySQL-python-1.2.4c1/temp/tmpre4Uzo
Now working in /tmp/easy_install-dxDCyG/MySQL-python-1.2.4c1/temp/tmpre4Uzo/distribute-0.6.28
Building a Distribute egg in /tmp/easy_install-dxDCyG/MySQL-python-1.2.4c1
/tmp/easy_install-dxDCyG/MySQL-python-1.2.4c1/distribute-0.6.28-py2.7.egg
zip_safe flag not set; analyzing archive contents...
Adding MySQL-python 1.2.4c1 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg
Processing dependencies for mysql-python
Finished processing dependencies for mysql-python


I had to update the python .egg fiile used for easy install for a 2.7.egg , done that and.....


[Only registered and activated users can see links]

Zachafer
12-07-2012, 03:51 PM
Good work! :)