错误:命令 'x86_64的-Linux的GNU的gcc的' 安装时的mysql

问题描述 投票:9回答:4

我安装的virtualenv Django的1.8.5和使用Python 3.4.3奋力显示它使用SQLite时,工作正常

我想用mysql和我想要使用安装的mysql

pip install mysqlclient

而我得到了以下信息

----------------------------------------
Failed building wheel for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Complete output from command /home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient:
running install
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
running build_ext
building '_mysql' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -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/sasidhar/django/env/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient" failed with error code 1 in /tmp/pip-build-5lj39q67/mysqlclient

我也尝试安装图书馆error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1建议

仍然问题仍然存在,请帮我解决这个问题 多谢你们!!

mysql django python-3.4
4个回答
30
投票

你需要安装python-dev的:

sudo apt-get install python-dev

而且,由于你使用python3:

sudo apt-get install python3-dev

这个命令应该可以帮助您。

如果您正在使用Mac OS,你可以尝试:

brew update && brew rm python3 && brew install python3

您需要冲泡已经安装,否则安装即可。这是在Mac OS中准备的软件包非常有用的。 http://brew.sh/


5
投票

对于使用python3.5那些:

apt-get install python3.5-dev
wget https://bootstrap.pypa.io/get-pip.py
python3.5 get-pip.py
pip3.5 install mysqlclient

3
投票

对于Ubuntu的,你还需要安装建立必要的

sudo apt-get install build-essential

0
投票

尝试了所有的上述建议和一些其他地方发现并没有什么工作。最终解决方案是相当简单的(ignacionf在GitHub上提供):

pip install git+https://github.com/PyMySQL/mysqlclient-python.git
© www.soinside.com 2019 - 2024. All rights reserved.