当前位置:   article > 正文

Mac 使用 pip install mysqlclient 爆错 error: subprocess-exited-with-error 解决办法

Mac 使用 pip install mysqlclient 爆错 error: subprocess-exited-with-error 解决办法

虚拟环境中安装 mysqlclient 发生报错:

pipenv install mysqlclient
  • 1

报错如下:

ERROR:pip.subprocessor:Getting requirements to build wheel exited with 1
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/resolver.py", line 645, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/resolver.py", line 612, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:       ^^^^^^^^
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/resolver.py", line 592, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:       ^^^^^^^^^^^^^
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/utils/resolver.py", line 918, in resolve_deps
[ResolutionFailure]:       results, hashes, internal_resolver = actually_resolve_deps(
[ResolutionFailure]:       ^^^^^^^^^^^^^^^^^^^^^^
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/utils/resolver.py", line 691, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/Users/zhangyongxin/.local/share/virtualenvs/movie-calendar-djapi-VxNe5-yZ/lib/python3.12/site-packages/pipenv/utils/resolver.py", line 448, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to inspect the versions actually installed in the virtualenv.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Getting requirements to build wheel exited with 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

解决办法如下:

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

如果不想安装 mysql server,只安装 mysql-client 也是可以的:

$ # 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
  • 1
  • 2
  • 3
  • 4

最后附上 pypi官方地址,有问题直接查官方文档,是最快,也是最靠谱的。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/298976
推荐阅读
相关标签
  

闽ICP备14008679号