安装python的MysqLclient==1.4.6报错
环境:
ubuntu18.04
python 3.6.8
Django 2.0
想要使用Django来操作MysqL,需要安装一个驱动程序。在python3中,选择用MysqLclient做驱动。
安装MysqLclient出现报错:
ERROR: Command errored out with exit status 1:
command: /home/renlei/.virtualenvs/mxonline/bin/python -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gfcy3s5k/MysqLclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gfcy3s5k/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-gfcy3s5k/MysqLclient/pip-egg-info
cwd: /tmp/pip-install-gfcy3s5k/MysqLclient/
Complete output (12 lines):
/bin/sh: 1: MysqL_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: MysqL_config: not found
Traceback (most recent call last):
File "<string>",line 1,in <module>
File "/tmp/pip-install-gfcy3s5k/MysqLclient/setup.py",line 16,in <module>
Metadata,options = get_config()
File "/tmp/pip-install-gfcy3s5k/MysqLclient/setup_posix.py",line 61,in get_config
libs = MysqL_config("libs")
File "/tmp/pip-install-gfcy3s5k/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.
解决方案:
1.先安装 客户端程序:
sudo apt install -y MysqL-client
2.基于python安装MysqLclient需要依次安装以下库:
sudo apt-get install libMysqLclient-dev
sudo apt install libssl-dev
sudo apt install libcrypto++-dev
3.使用pip安装MysqLclient
sudo pip3 install MysqLclient
或者在虚拟环境中用如下命令安装指定版本
(cootuu) root@VM-0-6-ubuntu:~# pip install MysqLclient==1.4.6
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。