0
我是新來的Python,我想安裝mysqldb模塊連接到我的數據庫,我已經嘗試「pip install mysql-python」 ,終端顯示:使用「pip安裝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/
如何解決這個問題?這是什麼意思? 謝謝!
你已經安裝了OpenSSL?因爲它抱怨沒有爲-lssl找到ld:library – EvgenyKolyakov
有'gcc'的依賴問題。解決使用安裝'gcc'。如果你是Linux,你可以安裝像'sudo apt-get install gcc' –
類似問題:https://stackoverflow.com/questions/7459766/installing-mysql-python –