Django 2 Linux mint 中的 Mysql 安装错误

安图

我尝试MySQLDjango. 为此,我需要mysqlclient使用以下命令进行安装

pip install mysqlclient

但它给了我以下错误

> /usr/local/lib/python2.7/dist-packages/pip-18.0-py2.7.egg/pip/_vendor/requests/__init__.py:83:
> RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may
> cause slowdown.   warnings.warn(warning, RequestsDependencyWarning)
> Collecting mysqlclient   Using cached
> https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
> Installing collected packages: mysqlclient   Running setup.py install
> for mysqlclient ... error
>     Complete output from command /usr/bin/python -u -c "import setuptools,
> tokenize;__file__='/tmp/pip-install-kP3VWP/mysqlclient/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-record-Znr67C/install-record.txt --single-version-externally-managed --compile:
>     running install
>     running build
>     running build_py
>     creating build
>     creating build/lib.linux-x86_64-2.7
>     copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
>     creating build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/compat.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
>     creating build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
>     running build_ext
>     building '_mysql' extension
>     creating build/temp.linux-x86_64-2.7
>     x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
>     _mysql.c:37:20: fatal error: Python.h: No such file or directory
>     compilation terminated.
>     error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>     
>     ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-kP3VWP/mysqlclient/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-record-Znr67C/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-kP3VWP/mysqlclient/

当我尝试这个命令时:

pip3 install mysqlclient

它给了我以下错误

Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-13zxsnds/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp5ktn63uopip-wheel- --python-tag cp35:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.3.13
You are using pip version 8.1.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我怎么才能安装mysqlclientLinux mint并连接MySQLDjango 2使用PIP 3?

刘强东

蟒蛇2:

sudo apt-get install python-dev libmysqlclient-dev

如果你使用python3:

sudo apt-get install python3-dev

在 ubuntu 上

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章