我是Python的新手,我想安装mysqldb模块连接到我的数据库,我已经尝试了“pip install mysql-python”,终端显示:
sudo pip install mysql-python
The directory '/Users/suoliyun/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/suoliyun/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysql-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 1.9MB/s
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command /Users/suoliyun/Library/Enthought/Canopy/edm/envs/User/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-DCyMvD/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 /tmp/pip-1dVZC1-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.6-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.6-x86_64-2.7
creating build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
creating build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-x86_64-2.7
gcc -fno-strict-aliasing -fno-common -dynamic -g -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.7.18_1/include/mysql -I/Users/suoliyun/Library/Enthought/Canopy/edm/envs/User/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-x86_64-2.7/_mysql.o
_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (how < 0 || how >= sizeof(row_converters)) {
~~~ ^ ~
1 warning generated.
gcc -bundle -undefined dynamic_lookup -g -arch x86_64 -headerpad_max_install_names -arch x86_64 build/temp.macosx-10.6-x86_64-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.7.18_1/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-x86_64-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 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/*/Library/Enthought/Canopy/edm/envs/User/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-DCyMvD/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 /tmp/pip-1dVZC1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-DCyMvD/mysql-python/
如何解决这个问题?这意味着什么? 谢谢!
答案 0 :(得分:0)
每当安装任何依赖于项目的python库时,总是在相应的虚拟环境中安装这些库
1. pip install virtualenv
2. virtualenv miscellaneous
3. source miscellaneous/bin/activate
4. pip install MySQL-python