我正试图导入MySQLdb,而它来了:>>> import MySQLdb
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named MySQLdb
所以我开始安装MySQLdb,方法是:
^{pr2}$
但是,我得到了错误信息:Collecting MySQL-Python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: MySQL-Python
Running setup.py install for MySQL-Python ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/y4/qxwc6ps56fv6bc94vyp3ccjr0000gn/T/pip-build-ejJODG/MySQL-Python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/y4/qxwc6ps56fv6bc94vyp3ccjr0000gn/T/pip-pLamdE-record/install-record.txt --single-version-externally-managed --compile:
以及cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. -Qunused-arguments -Qunused-arguments build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.6.27/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
然后,我试了一下:export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
但这没有任何意义。
然后我尝试了另一种方法:sudo pip install mysql-connector-python
然而,它也不起作用:Collecting mysql-connector-python
Could not find a version that satisfies the requirement mysql-connector-python (from versions: )
No matching distribution found for mysql-connector-python
因为我是mac和python的新手,我不知道发生了什么以及如何修复它。我已经在我的电脑里安装了python2.7.10。在