命令“python setup.py egg\u info”在/tmp/pip-install-fs0wmmw4/mysqlclient中失败,错误代码为1/

mlnl4t2r  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(379)

当我在ubuntu16.04中键入以下命令时

$ pip install mysqlclient

我得到以下错误:

`enter code here`Collecting mysqlclient
  Downloading https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 136kB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup_posix.py", line 26, 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-install-fs0wmmw4/mysqlclient/
eit6fx6z

eit6fx6z1#

经过一番调查,尝试不同的解决方案,我发现了以下几点:
1-大多数用户在ubuntu 16.04上通过apt get安装python。
2-ubuntu主存储库中的版本是3.5.x。这个 mysqlclient 与一起安装的 pip ,与版本低于v3.6的python3s存在问题。所以你应该安装python3.6。
3-如果您在windows上,则可以使用的编译版本 mysqlclient 作为轮锉。你可以在这里找到一些轮子文件。只需下载文件,然后:

pip install "path-of-wheel-file"

4-如果您使用的是ubuntu,请通过以下命令安装python3.6:

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6 python3.6-dev libmysqlclient-dev libmysqld-dev unzip

5-你应该更新 setuptools :

python -m pip install --upgrade pip setuptools wheel

对于python3.6:

python3.6 -m pip install --upgrade pip setuptools wheel

6-在最后一步,您应该从以下源安装mysqlclient:

wget https://github.com/PyMySQL/mysqlclient-python/archive/master.zip
unzip master.zip
cd mysqlclient-python-master
python setup.py install

如果您使用的是django 1.11 lts版本,则应克隆较旧的mysqlclient版本(例如:v1.3.13):

wget https://github.com/PyMySQL/mysqlclient-python/archive/1.3.13.zip
unzip 1.3.13.zip
cd mysqlclient-python-master
python setup.py install
4uqofj5v

4uqofj5v2#

请尝试以下说明:
https://github.com/pymysql/mysqlclient-python
或者如果您使用的是python3。执行以下命令:

sudo apt-get install libmysqlclient-dev

sudo pip3 install mysqlclient

他们都在我的案子里工作。
希望!!这很有帮助

相关问题