I am running Fedora Core 2. Previously, I had MySQLdb 1.2.1_p2 running fine with MySQL 3.23.58. However, I recently decided to update to MySQL 4.1.18 (from RPMs). Having done so, I verified which libraries were available:
Naturally, on trying to import MySQLdb, I get an ImportError.
My apologies if this is addressed elsewhere but I can't find anything in the README or otherwise that would explain why when I build, the old MySQL library is still referenced, given that I have done a seemingly clean update. I have tried building both static and non but both lead to the same result. I have also checked that the mysql_config command displays information relating to the new MySQL version.
Have I missed something really obvious?
Many thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have multiple versions of MySQL installed, and MySQLdb links against one when compiling but can't find this library when running/importing. Here are some library .so version numbers and versions of MySQL they correspond to:
10 -- 3.23
12 -- 4.0
14 -- 4.1
15 -- 5.0
You're building against 3.23 but also have 4.1 installed. Run mysql_config and see what happens. Chances are your 3.23 installation is not completely removed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any other way to tell if any other bits of 3.23 are lying around? In particular, which files might lead MySQLdb to link against the old version when compiling?
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Get rid of your build directory and rebuild, and post the output here if it does not work. It's not clear that you actually rebuilt against the new libraries anyway, re-reading your first post. Just doing setup.py build does not necessarily rebuild _mysql.so, since distutils uses timestamps to determine if something should be rebuilt, and upgrading MySQL would not affect the timestamps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am running Fedora Core 2. Previously, I had MySQLdb 1.2.1_p2 running fine with MySQL 3.23.58. However, I recently decided to update to MySQL 4.1.18 (from RPMs). Having done so, I verified which libraries were available:
/usr/lib/mysql/libmysqlclient_r.la
/usr/lib/mysql/libmysqlclient.la
/usr/lib/mysql/libmysqlclient_r.a
/usr/lib/mysql/libmysqlclient.a
/usr/lib/libmysqlclient_r.so
/usr/lib/libmysqlclient.so.14
/usr/lib/libmysqlclient.so.14.0.0
/usr/lib/libmysqlclient_r.so.14
/usr/lib/libmysqlclient.so
/usr/lib/libmysqlclient_r.so.14.0.0
I then ran
python setup.py build
and this was successful. The problem is that when I examine the shared library dependencies of _mysql.so, I get the following:
ldd build/lib.linux-i686-2.4/_mysql.so
Naturally, on trying to import MySQLdb, I get an ImportError.
My apologies if this is addressed elsewhere but I can't find anything in the README or otherwise that would explain why when I build, the old MySQL library is still referenced, given that I have done a seemingly clean update. I have tried building both static and non but both lead to the same result. I have also checked that the mysql_config command displays information relating to the new MySQL version.
Have I missed something really obvious?
Many thanks.
Bingo.
I had run setup.py clean but foolishly didn't actually remove the build directory. Removing it manually and rebuilding does the trick.
So the answer to my question, "Have I missed something really obvious?" is "Yes"! Too many late nights...
Thank you, Andy.
You have multiple versions of MySQL installed, and MySQLdb links against one when compiling but can't find this library when running/importing. Here are some library .so version numbers and versions of MySQL they correspond to:
10 -- 3.23
12 -- 4.0
14 -- 4.1
15 -- 5.0
You're building against 3.23 but also have 4.1 installed. Run mysql_config and see what happens. Chances are your 3.23 installation is not completely removed.
If I run mysql_config, I get the following:
--cflags [-I/usr/include/mysql -g -pipe -march=i386 -mcpu=i686]
--include [-I/usr/include/mysql]
--libs [-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm]
--libs_r [-L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread]
--socket [/var/lib/mysql/mysql.sock]
--port [3306]
--version [4.1.18]
--libmysqld-libs [-L/usr/lib/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt]
If I run rpm -qa | grep -i MySQL, I get this:
MySQL-server-4.1.18-0.glibc23
MySQL-devel-4.1.18-0.glibc23
MySQL-shared-4.1.18-0.glibc23
MySQL-client-4.1.18-0.glibc23
Is there any other way to tell if any other bits of 3.23 are lying around? In particular, which files might lead MySQLdb to link against the old version when compiling?
Thanks again.
Get rid of your build directory and rebuild, and post the output here if it does not work. It's not clear that you actually rebuilt against the new libraries anyway, re-reading your first post. Just doing setup.py build does not necessarily rebuild _mysql.so, since distutils uses timestamps to determine if something should be rebuilt, and upgrading MySQL would not affect the timestamps.