安装环境
django 2.2
centos 7
错误日志
代码语言:javascript复制pip install mysqlclient
代码语言:javascript复制(qingjiu) [root@VM_16_3_centos running]# pip install mysqlclient
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting mysqlclient
Downloading http://mirrors.tencentyun.com/pypi/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz (85 kB)
|████████████████████████████████| 85 kB 829 kB/s
ERROR: Command errored out with exit status 1:
command: /root/.pyenvs/qingjiu/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0ibh1u6c/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0ibh1u6c/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-0ibh1u6c/mysqlclient/pip-egg-info
cwd: /tmp/pip-install-0ibh1u6c/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-0ibh1u6c/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/tmp/pip-install-0ibh1u6c/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-0ibh1u6c/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法
代码语言:javascript复制yum install mysql-devel
代码语言:javascript复制(qingjiu) [root@VM_16_3_centos running]# yum install mysql-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.64-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-devel-5.5.64-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be updated
---> Package mariadb-libs.x86_64 1:5.5.64-1.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================
Installing:
mariadb-devel x86_64 1:5.5.64-1.el7 os 755 k
Updating for dependencies:
mariadb-libs x86_64 1:5.5.64-1.el7 os 759 k
Transaction Summary
==============================================================================================================================
Install 1 Package
Upgrade ( 1 Dependent package)
Total download size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/2): mariadb-libs-5.5.64-1.el7.x86_64.rpm | 759 kB 00:00:00
(2/2): mariadb-devel-5.5.64-1.el7.x86_64.rpm | 755 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------
Total 2.5 MB/s | 1.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:mariadb-libs-5.5.64-1.el7.x86_64 1/3
Installing : 1:mariadb-devel-5.5.64-1.el7.x86_64 2/3
Cleanup : 1:mariadb-libs-5.5.52-1.el7.x86_64 3/3
Verifying : 1:mariadb-devel-5.5.64-1.el7.x86_64 1/3
Verifying : 1:mariadb-libs-5.5.64-1.el7.x86_64 2/3
Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 3/3
Installed:
mariadb-devel.x86_64 1:5.5.64-1.el7
Dependency Updated:
mariadb-libs.x86_64 1:5.5.64-1.el7
Complete!
重新安装
代码语言:javascript复制(qingjiu) [root@VM_16_3_centos running]# pip install mysqlclient
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting mysqlclient
Downloading http://mirrors.tencentyun.com/pypi/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz (85 kB)
|████████████████████████████████| 85 kB 425 kB/s
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... done
Created wheel for mysqlclient: filename=mysqlclient-1.4.6-cp36-cp36m-linux_x86_64.whl size=96094 sha256=37e8b9aa00f7dc1e14388717188583be13fe35dc904e4b383d63396858bf7153
Stored in directory: /root/.cache/pip/wheels/4e/4e/1f/3546c278052537a8d28dc582b554d9697e477251750746251a
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6
可能还需要
如果还提示:
OSError: mysql_config not found
就试试:
代码语言:javascript复制ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config