mysql - 错误 : command 'x86_64-linux-gnu-gcc' when installing mysqlclient

标签 mysql django python-3.4

我在 virtualenv 中安装了 django 1.8.5 并使用 python 3.4.3 使用 sqlite 时,worked 显示it works 页面

我想使用 mysql,我正在尝试使用以下命令安装 mysqlclient

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 中建议的库

问题依旧 请帮我解决这个问题
多谢你们!!

最佳答案

你需要安装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

需要brew已经安装,否则可以安装。它对于在 Mac OS 中获取包非常有用。 http://brew.sh/

关于mysql - 错误 : command 'x86_64-linux-gnu-gcc' when installing mysqlclient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33315210/

相关文章:

python-3.4 - Pyramid.util.Request源代码

python - 编辑列表框中的对象及其来源列表

php - laravel 5.2 使用循环添加 orWhere 子句返回错误

mysql - 错误: Operand should contain 1 column(s)

python - 在 Django 管理界面中设置与所选模型类的关系

python - Django REST 框架 : read-write Custom Relational Fields

MySQL优化查询不在

php - 从多维数组中的多个表中获取数据

django - Django 有 SmallIntegerField 的原因是什么?

Python 3 字节码格式