当前位置:   article > 正文

pip安装mysqlclient报错 Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS_trying pkg-config --exists mysqlclient command 'pk

trying pkg-config --exists mysqlclient command 'pkg-config --exists mysqlcli

话不多说,报错如下:

  1. × Getting requirements to build wheel did not run successfully.
  2. │ exit code: 1
  3. ╰─> [24 lines of output]
  4. Trying pkg-config --exists mysqlclient
  5. Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
  6. Trying pkg-config --exists mariadb
  7. Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
  8. Trying pkg-config --exists libmariadb
  9. Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
  10. Traceback (most recent call last):
  11. File "/root/anaconda3/envs/zhaopin/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
  12. main()
  13. File "/root/anaconda3/envs/zhaopin/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
  14. json_out['return_val'] = hook(**hook_input['kwargs'])
  15. File "/root/anaconda3/envs/zhaopin/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
  16. return hook(config_settings)
  17. File "/tmp/pip-build-env-o5wmabdl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
  18. return self._get_build_requires(config_settings, requirements=['wheel'])
  19. File "/tmp/pip-build-env-o5wmabdl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
  20. self.run_setup()
  21. File "/tmp/pip-build-env-o5wmabdl/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
  22. exec(code, locals())
  23. File "<string>", line 155, in <module>
  24. File "<string>", line 49, in get_config_posix
  25. File "<string>", line 28, in find_package_name
  26. Exception: Can not find valid pkg-config name.
  27. Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
  28. [end of output]
  29. note: This error originates from a subprocess, and is likely not a problem with pip.
  30. error: subprocess-exited-with-error

关键问题就在这一句:

  1. Exception: Can not find valid pkg-config name.
  2. Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually

异常:找不到有效的pkg-config名称。 手动指定MYSQLCLIENT_CFLAGS和MYSQLCLIENT_LDFLAGS环境变量

 官网上其实给出了解答:

 # Debian / Ubuntu

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

# Red Hat / CentOS

sudo yum install python3-devel mysql-devel pkgconfig

 Mac 

macOS (Homebrew)

Install MySQL and mysqlclient(如果要安装MySQL):

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

If you don't want to install MySQL server, you can use mysql-client instead(不要安装MySQL):

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

官网文档:

  https://github.com/PyMySQL/mysqlclient#user-content-macos-homebrew

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

闽ICP备14008679号