pip3 install mysql_pip3 install mysqlclient 报错 OS

在Ubuntu系统中使用pip3安装mysqlclient时出现错误'Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1kuojk5w/mysqlclient/'。为了解决这个问题,需要先安装libmysqlclient-dev,通过运行'apt install libmysqlclient-dev'。安装完成后,再次执行pip3 install mysqlclient,安装成功。
摘要由CSDN通过智能技术生成

问题

root@iZj6c0yks0kczty7tn77eaZ:~# pip3 install mysqlclient

Collecting mysqlclient

Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/73/79/67ddf24ac31b05d741f0ac87fa612c7a11bab1b39b8270ed7344d149f8af/mysqlclient-1.4.2.tar.gz (85kB)

100% |████████████████████████████████| 92kB 52.1MB/s

Complete output from command python setup.py egg_info:

/bin/sh: 1: mysql_config: not found

Traceback (most recent call last):

File "", line 1, in

File "/tmp/pip-build-1kuojk5w/mysqlclient/setup.py", line 16, in

metadata, options = get_config()

File "/tmp/pip-build-1kuojk5w/mysqlclient/setup_posix.py", line 51, in get_config

libs = mysql_config("libs")

File "/tmp/pip-build-1kuojk5w/mysqlclient/setup_posix.py", line 29, 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-1kuojk5w/mysqlclient/

解决办法

先安装 libmysqlclient-dev

root@iZj6c0yks0kczty7tn77eaZ:~# apt install libmysqlclient-dev

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages were automatically installed and are no longer required:

libopts25 sntp

Use 'apt autoremove' to remove them.

The following additional packages will be installed:

libmysqlclient20 zlib1g-dev

The following NEW packages will be installed:

libmysqlclient-dev zlib1g-dev

The following packages will be upgraded:

libmysqlclient20

1 upgraded, 2 newly installed, 0 to remove and 94 not upgraded.

Need to get 2,157 kB of archives.

After this operation, 7,451 kB of additional disk space will be used.

Do you want to continue? [Y/n] Y

Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libmysqlclient20 amd64 5.7.25-0ubuntu0.18.04.2 [818 kB]

Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu bionic/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-0ubuntu2 [176 kB]

Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libmysqlclient-dev amd64 5.7.25-0ubuntu0.18.04.2 [1,164 kB]

Fetched 2,157 kB in 0s (17.7 MB/s)

(Reading database ... 111396 files and directories currently installed.)

Preparing to unpack .../libmysqlclient20_5.7.25-0ubuntu0.18.04.2_amd64.deb ...

Unpacking libmysqlclient20:amd64 (5.7.25-0ubuntu0.18.04.2) over (5.7.24-0ubuntu0.18.04.1) ...

Selecting previously unselected package zlib1g-dev:amd64.

Preparing to unpack .../zlib1g-dev_1%3a1.2.11.dfsg-0ubuntu2_amd64.deb ...

Unpacking zlib1g-dev:amd64 (1:1.2.11.dfsg-0ubuntu2) ...

Selecting previously unselected package libmysqlclient-dev.

Preparing to unpack .../libmysqlclient-dev_5.7.25-0ubuntu0.18.04.2_amd64.deb ...

Unpacking libmysqlclient-dev (5.7.25-0ubuntu0.18.04.2) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Setting up libmysqlclient20:amd64 (5.7.25-0ubuntu0.18.04.2) ...

Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-0ubuntu2) ...

Setting up libmysqlclient-dev (5.7.25-0ubuntu0.18.04.2) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

root@iZj6c0yks0kczty7tn77eaZ:~# pip3 install mysqlclient

Collecting mysqlclient

Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/73/79/67ddf24ac31b05d741f0ac87fa612c7a11bab1b39b8270ed7344d149f8af/mysqlclient-1.4.2.tar.gz (85kB)

100% |████████████████████████████████| 92kB 39.5MB/s

Building wheels for collected packages: mysqlclient

Running setup.py bdist_wheel for mysqlclient ... done

Stored in directory: /root/.cache/pip/wheels/14/ee/fb/a87e678e5e1737f95e6b268460a830ef87b921e1d83a60fa08

Successfully built mysqlclient

Installing collected packages: mysqlclient

Successfully installed mysqlclient-1.4.2

root@iZj6c0yks0kczty7tn77eaZ:~#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值