python用的是2.7.3
用pip安装mysql-python显示成功
(youngTree)junjielee@debian:~$ sudo pip install mysql-python
Downloading/unpacking mysql-python
Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
Running setup.py (path:/tmp/pip_build_root/mysql-python/setup.py) egg_info for package mysql-python
Installing collected packages: mysql-python
Running setup.py install for mysql-python
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g
In file included from _mysql.c:44:0:
/usr/include/mysql/my_config.h:422:0: warning: "HAVE_WCSCOLL" redefined [enabled by default]
In file included from /usr/include/python2.7/Python.h:8:0,
from _mysql.c:29:
/usr/include/python2.7/pyconfig.h:890:0: note: this is the location of the previous definition
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
Successfully installed mysql-python
Cleaning up...
我的dist-packages已经有两个文件夹:MYSQLdb和MySQL_python-1.2.5-py2.7.egg-info
现在的问题是,我在python交互界面,import MYSQLdb显示错误如下:
>>> import mysqlDB
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysqlDB
2 个解决方案
#1
名字错了:
import MySQLdb
#2
亲~ 很好,姐贴给你满分~~
还有一个问题:为什么在env虚拟环境里面用python,然后import MySQLdb不行的??
#1
名字错了:
import MySQLdb
#2
亲~ 很好,姐贴给你满分~~
还有一个问题:为什么在env虚拟环境里面用python,然后import MySQLdb不行的??