记一次python3 pip3 安装mysqlclient的故障排除

记一次python3 pip3 安装mysqlclient的故障排除

第一次报错日志
Collecting mysqlclient2.0.3
Using cached mysqlclient-2.0.3.tar.gz (88 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/setup.py’"’"’; file=’"’"’/tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-pip-egg-info-gqssblci
cwd: /tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/
Complete output (15 lines):
/bin/sh: mysql_config: 未找到命令
/bin/sh: mariadb_config: 未找到命令
/bin/sh: mysql_config: 未找到命令
mysql_config --version
mariadb_config --version
mysql_config --libs
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/setup.py”, line 15, in
metadata, options = get_config()
File “/tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/setup_posix.py”, line 70, in get_config
libs = mysql_config(“libs”)
File “/tmp/pip-install-32v58guj/mysqlclient_eabfb5b86ed046de88f908966a0eb896/setup_posix.py”, line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz#sha256=f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432 (from https://pypi.org/simple/mysqlclient/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient
2.0.3
ERROR: No matching distribution found for mysqlclient==2.0.3

查了下mysql_config为空

[root@localhost merge]# whereis mysql_config
mysql_config:
判断没安mysql-devel
[root@localhost merge]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[root@localhost yum.repos.d]# yum install mysql-devel

第二次安装

[root@localhost merge]# python3 -m pip install -r requirements.txt
Installing collected packages: pycparser, six, cffi, PyNaCl, cryptography, bcrypt, urllib3, PyMySQL, paramiko, mysqlclient, idna, configparser, chardet, certifi, sshtunnel, requests, python-dateutil, pymysql-utils, protobuf
Attempting uninstall: six
Found existing installation: six 1.11.0
Uninstalling six-1.11.0:
Successfully uninstalled six-1.11.0
Attempting uninstall: urllib3
Found existing installation: urllib3 1.24.2
Uninstalling urllib3-1.24.2:
Successfully uninstalled urllib3-1.24.2
Running setup.py install for mysqlclient … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-2i16qckh/mysqlclient_86e57fe1336e45a595d34d20c8ebc2ef/setup.py’"’"’; file=’"’"’/tmp/pip-install-2i16qckh/mysqlclient_86e57fe1336e45a595d34d20c8ebc2ef/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-ok63ihvj/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/mysqlclient
cwd: /tmp/pip-install-2i16qckh/mysqlclient_86e57fe1336e45a595d34d20c8ebc2ef/
Complete output (41 lines):
mysql_config --version
[‘8.0.21’]
mysql_config --libs
[’-L/usr/lib64/mysql’, ‘-lmysqlclient’, ‘-lpthread’, ‘-lz’, ‘-lm’, ‘-lrt’, ‘-lssl’, ‘-lcrypto’, ‘-ldl’]
mysql_config --cflags
[’-I/usr/include/mysql’, ‘-m64’]
ext_options:
library_dirs: [’/usr/lib64/mysql’]
libraries: [‘mysqlclient’, ‘pthread’, ‘m’, ‘rt’, ‘dl’]
extra_compile_args: [’-std=c99’, ‘-m64’]
extra_link_args: []
include_dirs: [’/usr/include/mysql’]
extra_objects: []
define_macros: [(‘version_info’, “(2,0,3,‘final’,0)”), (‘version’, ‘2.0.3’)]
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 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(2,0,3,‘final’,0) -D__version
=2.0.3 -I/usr/include/mysql -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -std=c99 -m64
unable to execute ‘gcc’: No such file or directory
error: command ‘gcc’ failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-2i16qckh/mysqlclient_86e57fe1336e45a595d34d20c8ebc2ef/setup.py’"’"’; file=’"’"’/tmp/pip-install-2i16qckh/mysqlclient_86e57fe1336e45a595d34d20c8ebc2ef/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-ok63ihvj/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/mysqlclient Check the logs for full command output.

安GCC试试

[root@localhost merge]# yum install gcc
结果报错一样
后来百度
[root@localhost merge]# yum install -y python3-devel

[root@localhost src]# python3 -m pip install -r requirements.txt
省略安装过程…
最后返回 OK
Successfully installed certifi-2020.12.5 chardet-4.0.0 configparser-5.0.2 idna-2.10 mysqlclient-2.0.3 protobuf-3.11.2 pymysql-utils-2.1.5 python-dateutil-2.8.1 requests-2.25.1 sshtunnel-0.4.0

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值