pip install mysqlclient安装失败经历(macbook m1pro)

记录一次安装mysqlclient的经历

使用命令安装 python3.11  -m install mysqlclient==2.2,出现以下报错

温馨提示:

        如果大家也是MacBook m系列芯片的电脑,建议直接按照官网步骤安装,轻松完成安装,没有必要在花费大量的时间去找安装教程,同时还不一定安装成功!!!

        因为我好久没有用win了,不了解win,这里只能分享MacBook的!!!

 Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
      Traceback (most recent call last):
        ..................

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

× 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.

         原因说到底,是因为mysqlclient需要安装依赖,我们只用安装mysqlclient所需要的依赖包,才能够正常安装成功!!!

        去找了很多安装教程,下载包下来在安装,但就是没有arm架构的包,而且都是win的,没法安装,最后根据官网安装的方式来,很简单的就完成安装了!!!

        根据官方安装教程:https://pypi.org/project/mysqlclient/#:~:text=Building%EE%80%80%20mysqlclient%EE%80%81

安装步骤

# Install MySQL and mysqlclient:

$ # Assume you are activating Python 3 venv
$ brew install mysql pkg-config
$ pip install mysqlclient

# If you don't want to install MySQL server, you can use mysql-client instead:

$ # Assume you are activating Python 3 venv
$ brew install mysql-client pkg-config
$ export PKG_CONFIG_PATH="$(brew --prefix)/opt/mysql-client/lib/pkgconfig"
$ pip install mysqlclient

        因为我下载安装过MySQL,所以没有用brew安装MySQL,但是注意:仍然会报同样的错误!!!

$ brew install pkg-config

$ python3.11 -m install pip install mysqlclient

        后面,我抱着尝试着心态使用brew安装MySQL

 $ brew install mysql

        结果直接就是,安装成功了!!!! 

[dealmon3w@xiaoguodong~ ]% python3.11 -m pip install mysqlclient==2.2
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting mysqlclient==2.2
  Using cached https://mirrors.aliyun.com/pypi/packages/de/9c/b176826e8994551ce826404dab97e305a4bb76c8b0a4e016fabda2901c71/mysqlclient-2.2.0.tar.gz (89 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (pyproject.toml) ... done
  Created wheel for mysqlclient: filename=mysqlclient-2.2.0-cp311-cp311-macosx_13_0_arm64.whl size=75162 sha256=e40ea9c45f5603ec6dee0f033c8fd1b518ce88eaa435d47dc66625326538a35a
  Stored in directory: /Users/dealmon3w/Library/Caches/pip/wheels/66/7d/a9/3d017a43915ea53fc41a52983a1cd4ae9b2c114b936ef2f3de
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.0 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值