简体   繁体   English

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

[英]Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-fs0wmmw4/mysqlclient/

When I type the following command in Ubuntu 16.04当我在 Ubuntu 16.04 中键入以下命令时

$ pip install mysqlclient

I get the following error:我收到以下错误:

`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/

Try these instructions:试试这些说明:

https://github.com/PyMySQL/mysqlclient-python https://github.com/PyMySQL/mysqlclient-python

Or if you are using python 3. Go with these commands:或者,如果您使用的是 python 3. 使用这些命令:

sudo apt-get install libmysqlclient-dev

sudo pip3 install mysqlclient

They both worked in my case.他们都在我的情况下工作。

Hope!!希望!! this helps这有帮助

I have just faced with this problem on Debian 10:我刚刚在 Debian 10 上遇到了这个问题:

According to github ( https://github.com/PyMySQL/mysqlclient ) now should use this:根据 github ( https://github.com/PyMySQL/mysqlclient ) 现在应该使用这个:

If you are on # Debian / Ubuntu first run:如果您使用的是 # Debian / Ubuntu,请先运行:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

If you are on # Red Hat / CentOS first run:如果你在#Red Hat/CentOS 上第一次运行:

sudo yum install python3-devel mysql-devel

Then you can install mysqlclient:然后你可以安装mysqlclient:

pip install mysqlclient

After some investigations, and trying different solutions, I found out some points as below:经过一些调查,并尝试了不同的解决方案,我发现了以下几点:

1- Most of the users install the Python from apt-get on Ubuntu 16.04. 1- 大多数用户在 Ubuntu 16.04 上从 apt-get 安装 Python。

2- The version which is exist on the main Ubuntu repository, is 3.5.x. 2- Ubuntu 主存储库中存在的版本是 3.5.x。 The mysqlclient that you install with pip , has problem with python3s whose version are under the v3.6.您使用pip安装的mysqlclient与版本低于 v3.6 的 python3s 有问题。 So you should install Python3.6.所以你应该安装Python3.6。

3- If you are on Windows, you could use a compiled version of mysqlclient as wheel file. 3- 如果您使用的是 Windows,则可以使用mysqlclient的编译版本作为轮文件。 You could find some of wheel files, here .您可以在此处找到一些车轮文件。 Just download the file, and then:只需下载文件,然后:

pip install "path-of-wheel-file"

4- If you are using Ubuntu, as described here , install the python3.6 via these commands: 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- You should update setuptools : 5- 您应该更新setuptools

python -m pip install --upgrade pip setuptools wheel

for python3.6:对于python3.6:

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

6- At the last step, you should install mysqlclient from source: 6- 在最后一步,您应该从源代码安装 mysqlclient:

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

If your are using Django 1.11 LTS version, you should clone an older mysqlclient version (ex: v1.3.13):如果您使用的是 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

Taking up this valuable comment from the most voted answer ,从投票最多的答案中提取这个有价值的评论

apt-get install python-mysqldb

solves this.解决这个问题。

Of course, if you want to use mysql, you will also need to install not just the python package for mysql, but also the mysql client itself with:当然,如果你想使用 mysql,你不仅需要安装 mysql 的 python 包,还需要安装 mysql 客户端本身:

apt-get install -y --no-install-recommends mysql-client

For instance, in a Dockerfile, it would look like:例如,在 Dockerfile 中,它看起来像:

RUN apt-get update
RUN apt-get install -y python-pip libmysqlclient-dev python-dev python-mysqldb

RUN apt-get install -y --no-install-recommends mysql-client

Thanks go to Docker, MySQL - command not found in .sh file感谢Docker,MySQL - 在 .sh 文件中找不到命令

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命令“ python setup.py egg_info”在/ tmp / pip-install-jsegcbha / mysqlclient /中失败,错误代码为1 - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-jsegcbha/mysqlclient/ 命令“ python setup.py egg_info”在/ tmp / pip-build-hg0dbjgz / mysqlclient /中失败,错误代码为1 - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-hg0dbjgz/mysqlclient/ / tmp / pip-install-rJRUpL / pyfinite /中的命令“ python setup.py egg_info”失败,错误代码为1 - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-rJRUpL/pyfinite/ 命令“ python setup.py egg_info”在/ tmp / pip-install-8ryfpf0v / unroll /中失败,错误代码为1 - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-8ryfpf0v/unroll/ ctcdecode 安装失败 - 命令“python setup.py egg_info”在 /tmp/pip-req-build-7zcjual1/ 中失败,错误代码为 1 - ctcdecode install fail - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-7zcjual1/ 命令“python setup.py egg_info”失败,错误代码 1 在 /tmp/pip-install-mqa_uywo/grpcio/ - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-mqa_uywo/grpcio/ 命令“python setup.py egg_info”在 /tmp/pip-install-xaum7z8f/supervisor/ 中失败,错误代码为 1 - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xaum7z8f/supervisor/ / tmp / pip-install-_p77_6kw / poster /中的命令“ python setup.py egg_info”失败,错误代码为1 - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-_p77_6kw/poster/ 命令“python setup.py egg_info”失败,错误代码 1 在 /tmp/pip-install-xtrlkujj/pyaudio/ - Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-install-xtrlkujj/pyaudio/ Python pip安装给出“命令”“ python setup.py egg_info”失败,错误代码为1” - Python pip install gives “Command ”python setup.py egg_info“ failed with error code 1”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM