ubuntu22.04使用pip install mysqlclient安装失败

文章讲述了在Ubuntu22.04系统中,用户尝试通过pipinstallmysqlclient时遇到的安装失败,主要问题是缺少pkg-config。给出了安装pkg-config以及解决依赖问题的步骤,包括apt-get安装相关开发工具和库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:辣椒小鱼の博客 - ubuntu22.04使用pip install mysqlclient安装失败 (chillifish.cn)

$ pip install mysqlclient 
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      /bin/sh: 1: pkg-config: not found
      /bin/sh: 1: pkg-config: not found
      Trying pkg-config --exists mysqlclient

......

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

第一处错误有明确的提示,缺少pkg-config。解决办法:

sudo apt-get install pkg-config

第二处错误很模糊,note: This error originates from a subprocess, and is likely not a problem with pip. 多数由于依赖问题导致。

网上查一下mysqlclient安装包所有需要的依赖项,逐个测试

sudo apt-get install python3 python-dev python3-dev  -y
sudo apt-get install     build-essential libssl-dev libffi-dev -y
sudo apt-get install     libxml2-dev libxslt1-dev zlib1g-dev  -y
sudo apt-get install     python-pip -y
pip install mysqlclient

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值