Django 2 Linux Mint中的MySQL安装错误

时间:2018-08-13 11:51:53

标签: python django pip

我尝试将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.

如何在mysqlclient中安装Linux mint并使用pip3将MySQLDjango 2连接?

1 个答案:

答案 0 :(得分:4)

python2:

comparator: function(filterLocalDateAtMidnight, cellValue) {
      //using moment js
      var dateAsString = moment(cellValue).format('DD/MM/YYYY');
      var dateParts = dateAsString.split("/");
      var cellDate = new Date(Number(dateParts[2]), Number(dateParts[1]) - 1, Number(dateParts[0]));

      if (filterLocalDateAtMidnight.getTime() == cellDate.getTime()) {
        return 0
      }

      if (cellDate < filterLocalDateAtMidnight) {
        return -1;
      }

      if (cellDate > filterLocalDateAtMidnight) {
        return 1;
      }
    }

如果您使用python3:

sudo apt-get install python-dev libmysqlclient-dev

在Ubuntu上