当前位置:   article > 正文

MAC安装mysqlclient失败,× Getting requirements to build wheel did not run successfully.│ exit code: 1╰─

getting requirements to build wheel did not run successfully

问题:

在使用django项目安装mysqlclient时出现以下错误:

  1. Collecting mysqlclient
  2. Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  3. Installing build dependencies ... done
  4. Getting requirements to build wheel ... error
  5. error: subprocess-exited-with-error
  6. × Getting requirements to build wheel did not run successfully.
  7. exit code: 1
  8. ╰─> [27 lines of output]
  9. /bin/sh: mysql_config: command not found
  10. /bin/sh: mariadb_config: command not found
  11. /bin/sh: mysql_config: command not found
  12. mysql_config --version
  13. mariadb_config --version
  14. mysql_config --libs
  15. Traceback (most recent call last):
  16. File "/Users/ww/IT/PycharmProject/pyproject/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
  17. main()
  18. File "/Users/ww/IT/PycharmProject/pyproject/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
  19. json_out['return_val'] = hook(**hook_input['kwargs'])
  20. File "/Users/ww/IT/PycharmProject/pyproject/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
  21. return hook(config_settings)
  22. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-build-env-w6vliiy5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
  23. return self._get_build_requires(config_settings, requirements=['wheel'])
  24. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-build-env-w6vliiy5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
  25. self.run_setup()
  26. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-build-env-w6vliiy5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 487, in run_setup
  27. super(_BuildMetaLegacyBackend,
  28. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-build-env-w6vliiy5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup
  29. exec(code, locals())
  30. File "<string>", line 15, in <module>
  31. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-install-9ai0k4t1/mysqlclient_68c540255d6b42808120a9e63553ac4d/setup_posix.py", line 70, in get_config
  32. libs = mysql_config("libs")
  33. File "/private/var/folders/w6/3qy3y8294l9bv15sxd54n0mm0000gn/T/pip-install-9ai0k4t1/mysqlclient_68c540255d6b42808120a9e63553ac4d/setup_posix.py", line 31, in mysql_config
  34. raise OSError("{} not found".format(_mysql_config_path))
  35. OSError: mysql_config not found
  36. [end of output]
  37. note: This error originates from a subprocess, and is likely not a problem with pip.
  38. error: subprocess-exited-with-error
  39. × Getting requirements to build wheel did not run successfully.
  40. exit code: 1
  41. ╰─> See above for output.

解决方案:

1、先去登录brew官网:

macOS(或 Linux)缺失的软件包的管理器 — Homebrew

复制以下代码,到mac终端运行:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装好后根据提示运行一下两端代码:

1、代码:

(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/ww/.zprofile

   

2、代码:

eval "$(/opt/homebrew/bin/brew shellenv)"

终端运行完后,确认brew已经安装完毕可以启动

brew help确认是否安装好

好了后,继续运行这两段代码:

  1. $ brew install mysql
  2. $ pip install mysqlclient

紧接着就是搞定

 

  1. Successfully built mysqlclient
  2. Installing collected packages: mysqlclient
  3. Successfully installed mysqlclient-2.1.1

看到这个恭喜你! 

 

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

闽ICP备14008679号