无法在python3 virtualenv中安装mysqlclient

前端之家收集整理的这篇文章主要介绍了无法在python3 virtualenv中安装mysqlclient前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想用MySQLPython 3运行django.我使用virtualenv初始化虚拟环境–no-site-packages -p python3 ./.然后我用pip安装了django和wheel,所以pip冻结了

django==1.8.3
wheel==0.24.0

然后我尝试使用pip install MysqLclient安装MysqLclient,但结束了

Downloading/unpacking MysqLclient
Downloading MysqLclient-1.3.6.tar.gz (78kB): 78kB downloaded
Running setup.py (path:/tmp/pip-build-jpdlrnc8/MysqLclient/setup.py) egg_info for package MysqLclient

Installing collected packages: MysqLclient
Running setup.py install for MysqLclient
building '_MysqL' extension
i586-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/MysqL -I/usr/include/python3.4m -I/home/ondra/zelvovani/include/python3.4m -c _MysqL.c -o build/temp.linux-i686-3.4/_MysqL.o -DBIG_JOINS=1 -fno-strict-aliasing -DTAOCRYPT_DISABLE_X86ASM -g -DNDEBUG
error: command 'i586-linux-gnu-gcc' Failed with exit status 1
Complete output from command /home/ondra/zelvovani/bin/python3 -c "import setuptools,tokenize;__file__='/tmp/pip-build-jpdlrnc8/MysqLclient/setup.py';exec(compile(getattr(tokenize,'open',open)(__file__).read().replace('\r\n','\n'),__file__,'exec'))" install --record /tmp/pip-fa_6nkh3-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ondra/zelvovani/include/site/python3.4:
running install

running build

running build_py

creating build

creating build/lib.linux-i686-3.4

copying _MysqL_exceptions.py -> build/lib.linux-i686-3.4

creating build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/__init__.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/compat.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/converters.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/connections.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/cursors.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/release.py -> build/lib.linux-i686-3.4/MysqLdb

copying MysqLdb/times.py -> build/lib.linux-i686-3.4/MysqLdb

creating build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/__init__.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/CR.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/ER.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/FLAG.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/REFRESH.py -> build/lib.linux-i686-3.4/MysqLdb/constants

copying MysqLdb/constants/CLIENT.py -> build/lib.linux-i686-3.4/MysqLdb/constants

running build_ext

building '_MysqL' extension

creating build/temp.linux-i686-3.4

i586-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,1) -D__version__=1.3.6 -I/usr/include/MysqL -I/usr/include/python3.4m -I/home/ondra/zelvovani/include/python3.4m -c _MysqL.c -o build/temp.linux-i686-3.4/_MysqL.o -DBIG_JOINS=1 -fno-strict-aliasing -DTAOCRYPT_DISABLE_X86ASM -g -DNDEBUG

error: command 'i586-linux-gnu-gcc' Failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/ondra/zelvovani/bin/python3 -c "import setuptools,'exec'))" install --record /tmp/pip-fa_6nkh3-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ondra/zelvovani/include/site/python3.4 Failed with error code 1 in /tmp/pip-build-jpdlrnc8/MysqLclient
Storing debug log for failure in /home/ondra/.pip/pip.log

我已经安装了libMysqLclient-dev,python3-dev,zlib1g-dev(这是在stackoverflow中的其他问题中提出的包).

你有什么想法,我做错了什么?

最佳答案
使用pyMysqL它应该解决你的问题.使用pip3安装pyMysqL.安装完成后,在文件目录project / project / __ init__.py中写下这个

import pyMysqL 
pyMysqL.install_as_MysqLdb()

注意: – project是django项目的名称.

原文链接:https://www.f2er.com/mysql/433811.html

猜你在找的MySQL相关文章