我尝试安装 mysqlclient,但它提示 mysql_config 文件不存在。阅读文档后。我尝试安装 sudo yum install mariadb-devel 和 sudo yum install mysql-devel 。我仍然遇到同样的错误。我使用的是centos 7
sudo pip install mysqlclient
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/home/bramaraju/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/bramaraju/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Looking in indexes: https://security_automation:****@box.jfrog.io/box/api/pypi/Security-PyPi-Local/simple, https://security_automation:****@box.jfrog.io/box/api/pypi/box-pypi/simple, https://pypi.python.org/simple
Collecting mysqlclient
Downloading https://box.jfrog.io/box/api/pypi/box-pypi/packages/packages/f8/9b/5db9a03e2088a87c26e3e4d4c7f7e8f4c2dbae610f9521cdfac15755a795/mysqlclient-1.4.5.tar.gz (86kB)
|████████████████████████████████| 92kB 5.3MB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-KrW_Ny/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-KrW_Ny/mysqlclient/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-install-KrW_Ny/mysqlclient/pip-egg-info
cwd: /tmp/pip-install-KrW_Ny/mysqlclient/
Complete output (12 lines):
sh: mysql_config: command not found
sh: mariadb_config: command not found
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-KrW_Ny/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
EnvironmentError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
但是在安装mysql-devel时。我收到以下错误。所以使用 sudo yum install mysql-devel --skip-broken 安装
--> Finished Dependency Resolution
Error: Package: zlib-devel-1.2.7-18.el7.x86_64 (cie-base)
Requires: zlib = 1.2.7-18.el7
Installed: lib64zlib1-1.2.8-7.1.mga5.x86_64 (@security-rpm-local-thirdparty)
zlib = 1.2.8-7.1.mga5
Available: zlib-1.2.7-18.el7.i686 (cie-base)
zlib = 1.2.7-18.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
最佳答案
您的 zlib 来自 repo @security-rpm-local-thirdparty,这是有冲突的。拥有这样的软件包将与您想要安装的许多 Centos/RHEL 软件包发生冲突。
建议删除lib64zlib1/1.2.8-7.1.mga5并安装系统zlib。
关于mysql - 无法使用pip安装mysqlclient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58757987/