Reputation: 46899
on ubuntu i have installed mysql but still i cannot import mysql database. Below are the steps that i followed.Can any one point me to a solution to this (Other info is ubuntu is installed on a virtual box hope that should not matter).Python version is 2.6.5
root@rajeev-laptop:/opt/s/site# apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
python-mysqldb-dbg
The following NEW packages will be installed:
python-mysqldb
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/76.6kB of archives.
After this operation, 283kB of additional disk space will be used.
Selecting previously deselected package python-mysqldb.
(Reading database ... 151280 files and directories currently installed.)
Unpacking python-mysqldb (from .../python-mysqldb_1.2.2-10build1_i386.deb) ...
Setting up python-mysqldb (1.2.2-10build1) ...
Processing triggers for python-support ...
root@rajeev-laptop:/opt/s/site# python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] 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
>>>
Upvotes: 1
Views: 1382
Reputation: 9674
Ahh these problem... invest some time in virtualenv for python. It will pay off =)
Upvotes: 0
Reputation: 46899
All,
I got this resolved by the following, in my /etc/bash.bashrc i was importing a pythonpath as /opt/s/ Where django and my site resided.When i removed the following from the pythonpath the import MySQLdb worked..Hope this post will help somebody..
Upvotes: 1
Reputation: 5149
The package information shows you what's going on (ubuntu 12.04):
apt-cache show python-mysqldb
[...]
Provides: python2.7-mysqldb
Depends: python2.7, [...]
Python-Version: 2.7
[...]
This package is for python 2.7 - so it's not installed for 2.6. execute python2.7
in a shell and try the import again.
(if you have an older ubuntu version, execute the apt-cache command on your machine to check if this is the case in your version as well)
Upvotes: 0
Reputation: 329
I would check the Python PATH and make a manual build of MySQLDB download. Download the installation files from this source forge site.
Upvotes: 0