公司买了一台测试服务器,需要把测试服务器搭一下,小记搭建过程遇到的小问题
基本版本信息
- centos7.6
- python3.7
- django2.2
安装mysqlclient需要如下错误:
# pip3 install mysqlclient
Collecting mysqlclient
Downloading http://mirrors.aliyun.com/pypi/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
100% |████████████████████████████████| 92kB 18.7MB/s
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-tv34qz2u/mysqlclient/setup.py", line 18, in <module>
metadata, options = get_config()
File "/tmp/pip-build-tv34qz2u/mysqlclient/setup_posix.py", line 53, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-tv34qz2u/mysqlclient/setup_posix.py", line 28, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tv34qz2u/mysqlclient/
---------------------
错误信息可以看出来, mysql_config这个依赖包出现了问题。
解决问题:
添加软连接
ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
添加软连接以后还是不行的话呢,再做如下操作:
# 先安装mysql-devel,后安装mysqlclient
yum install mysql-devel
pip3 install mysqlclient
完美解决问题
[root@iZwz98au0xz9ipxecv5nayZ web]# pip3 install mysqlclient
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting mysqlclient
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
|████████████████████████████████| 92kB 11.3MB/s
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... done
Stored in directory: /root/.cache/pip/wheels/b0/3e/e7/a7697d41d7f04f677196576c9a4edb6e749788fd8a4bd6e0ce
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2.post1