简体   繁体   English

在 ubuntu 18.04 上为 python 3.7.5 安装 mysqclient 时出错

[英]Error installing mysqclient for python 3.7.5 on ubuntu 18.04

this is the error i'm getting:这是我得到的错误:

creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb


copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
  creating build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.linux-x86_64-3.7



creating build/temp.linux-x86_64-3.7/MySQLdb
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(2,0,0,'dev',1) -D__version__=2.0.0dev1 -I/usr/include/mysql -I/usr/include/python3.7m -I/deployment/portfolio/venv/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
  unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: 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 ... error
    ERROR: Command errored out with exit status 1:
     command: /deployment/portfolio/venv/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-vbpwzo_w/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-vbpwzo_w/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-i8oey5_m/install-record.txt --single-version-externally-managed --compile --install-headers /deployment/portfolio/venv/include/site/python3.7/mysqlclient
         cwd: /tmp/pip-req-build-vbpwzo_w/
    Complete output (29 lines):
    /deployment/portfolio/venv/lib/python3.7/site-packages/setuptools/dist.py:476: UserWarning: Normalizing '2.0.0dev1' to '2.0.0.dev1'
      normalized_version,
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.linux-x86_64-3.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.linux-x86_64-3.7/MySQLdb
    creating build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.7/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/MySQLdb
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(2,0,0,'dev',1) -D__version__=2.0.0dev1 -I/usr/include/mysql -I/usr/include/python3.7m -I/deployment/portfolio/venv/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /deployment/portfolio/venv/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-vbpwzo_w/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-vbpwzo_w/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-i8oey5_m/install-record.txt --single-version-externally-managed --compile --install-headers /deployment/portfolio/venv/include/site/python3.7/mysqlclient Check the logs for full command output.

i have seen so many questions, and installed so many things as:我看到了很多问题,并安装了很多东西:

  • python3.7-dev python3.7-dev
  • python3-dev python3-dev
  • python-dev蟒蛇开发
  • pip install mysqlclient==1.4.2.post1 pip 安装 mysqlclient==1.4.2.post1
  • pip install mysqlclient pip 安装 mysqlclient
  • sudo apt-get install python3.7-dev default-libmysqlclient-dev sudo apt-get install python3.7-dev 默认-libmysqlclient-dev
  • apt-get install python3.7-dev libmysqlclient-dev apt-get install python3.7-dev libmysqlclient-dev
  • sudo apt-get install libssl-dev sudo apt-get install libssl-dev
  • pip install mysql-connector-python pip 安装 mysql-connector-python

nothing seem to work for me, and i don't know what to do anymore, any help is appreciated.似乎没有什么对我有用,我不知道该怎么办了,任何帮助表示赞赏。

Problem Solved thanks to Nigel Savage , as he suggested i'll list what i did:感谢Nigel Savage解决了问题,因为他建议我列出我所做的:

  • Ubuntu version 18.04.03 LTS Ubuntu 版本 18.04.03 LTS
  • VPS: Google cloud instance VPS:谷歌云实例
  • python 3.7.5 using virtualenv python 3.7.5 使用 virtualenv
  • apt-get install python3.7-dev apt-get 安装 python3.7-dev
  • apt-get install python3.7-dev libmysqlclient-dev apt-get install python3.7-dev libmysqlclient-dev
  • apt install build-essential apt install build-essential
  • pip install mysqlclient==1.4.2.post1 pip 安装 mysqlclient==1.4.2.post1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM