部署到centos虚拟环境安装依赖报错,mysql-client

来源:3-10 python3基本讲解 和 linux 安装Python3

丛从绿草

2021-05-18

图片描述

Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /root/bazai_mall/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’; file=’"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-zxkcwl4w
cwd: /tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/
Complete output (46 lines):
mysql_config --version
[‘5.5.68’]
mysql_config --libs
[’-L/usr/lib64/mysql’, ‘-lmysqlclient’, ‘-lpthread’, ‘-lz’, ‘-lm’, ‘-ldl’, ‘-lssl’, ‘-lcrypto’]
mysql_config --cflags
[’-I/usr/include/mysql’]
ext_options:
library_dirs: [’/usr/lib64/mysql’]
libraries: [‘mysqlclient’, ‘pthread’, ‘m’, ‘dl’]
extra_compile_args: [’-std=c99’]
extra_link_args: []
include_dirs: [’/usr/include/mysql’]
extra_objects: []
define_macros: [(‘version_info’, “(2,0,3,‘final’,0)”), (‘version’, ‘2.0.3’)]
/root/bazai_mall/lib/python3.6/site-packages/setuptools/dist.py:645: UserWarning: Usage of dash-separated ‘index-url’ will not be supported in future versions. Please use the underscore name ‘index_url’ instead
% (opt, underscore_opt))
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb.mysql’ extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,3,‘final’,0) -D__version
=2.0.3 -I/usr/include/mysql -I/root/bazai_mall/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -std=c99
MySQLdb/_mysql.c:46:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘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: zipp, typing-extensions, MarkupSafe, dataclasses, Werkzeug, Jinja2, itsdangerous, importlib-metadata, greenlet, click, SQLAlchemy, flask, mysqlclient, flask-sqlalchemy, flask-script
Running setup.py install for mysqlclient … error
ERROR: Command errored out with exit status 1:
command: /root/bazai_mall/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’; file=’"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-zqof_f1x/install-record.txt --single-version-externally-managed --compile --install-headers /root/bazai_mall/include/site/python3.6/mysqlclient
cwd: /tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/
Complete output (46 lines):
mysql_config --version
[‘5.5.68’]
mysql_config --libs
[’-L/usr/lib64/mysql’, ‘-lmysqlclient’, ‘-lpthread’, ‘-lz’, ‘-lm’, ‘-ldl’, ‘-lssl’, ‘-lcrypto’]
mysql_config --cflags
[’-I/usr/include/mysql’]
ext_options:
library_dirs: [’/usr/lib64/mysql’]
libraries: [‘mysqlclient’, ‘pthread’, ‘m’, ‘dl’]
extra_compile_args: [’-std=c99’]
extra_link_args: []
include_dirs: [’/usr/include/mysql’]
extra_objects: []
define_macros: [(‘version_info’, “(2,0,3,‘final’,0)”), (‘version’, ‘2.0.3’)]
/root/bazai_mall/lib/python3.6/site-packages/setuptools/dist.py:645: UserWarning: Usage of dash-separated ‘index-url’ will not be supported in future versions. Please use the underscore name ‘index_url’ instead
% (opt, underscore_opt))
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb.mysql’ extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,3,‘final’,0) -D__version
=2.0.3 -I/usr/include/mysql -I/root/bazai_mall/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -std=c99
MySQLdb/_mysql.c:46:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
error: command ‘gcc’ failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /root/bazai_mall/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’; file=’"’"’/tmp/pip-install-02eo3qto/mysqlclient_8b796ef18cd4463caeafcc5698ca5c2e/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-zqof_f1x/install-record.txt --single-version-externally-managed --compile --install-headers /root/bazai_mall/include/site/python3.6/mysqlclient Check the logs for full command output.

这里不知道要怎么解决了, 搞不懂啊。我是(windows)本地开发的,然后git clone 到centos系统上,安装了python,安装了虚拟环境, 现在安装依赖出现异常。

写回答

1回答

编程浪子

2021-05-19

你好

执行如下命令然后再试试

yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel  mysql-devel gcc gcc-devel python-devel  libffi-devel


0
2
丛从绿草
我后来在本地的虚拟机上重新操作了一遍, 然后依赖是可以成功安装了,现在python manager.py runserver的时候, 提示报错, ModuleNotFoundError: No module named 'flask._compat', 不知道为什么会这样, 好奇怪。
2021-05-19
共2条回复

Python Flask构建微信小程序订餐系统(可用于毕设)

微信小程序 + Python Flask 打造订餐系统全栈应用,可用于毕设。

1709 学习 · 1889 问题

查看课程