Failed building wheel for mysqlclient on macOS.

huangapple go评论107阅读模式
英文:

Failed building wheel for mysqlclient on macOS

问题

I have been troubleshooting this problem for the past 3 days, tried every method in stack and no luck, I am relatively new to Django and python so any suggestions will be greatly appreciated.
所以我在过去的3天里一直在解决这个问题,尝试了堆栈中的每种方法,但没有成功,我对Django和Python相对较新,因此非常感谢任何建议。

so I have been having a problem with installing mysqlclient through "pipenv install mysqlclient"
因此,我在通过"pipenv install mysqlclient"安装mysqlclient时遇到了问题
returning: ERROR: Failed building wheel for mysqlclient
返回:错误:构建mysqlclient的轮失败

full summary:
完整的摘要:

  1. Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
  2. 提示Pipenv发现自己正在虚拟环境中运行因此它将自动使用该环境而不是为任何项目创建自己的环境您可以设置PIPENV_IGNORE_VIRTUALENVS=1以强制pipenv忽略该环境并创建自己的环境您可以设置PIPENV_VERBOSITY=-1以抑制此警告
  3. Installing mysqlclient...
  4. 正在安装mysqlclient...
  5. Resolving mysqlclient...
  6. 正在解决mysqlclient...
  7. Installing...
  8. 正在安装...
  9. Installing mysqlclient...[31m[1mError: [0m An error occurred while installing [32mmysqlclient[0m!
  10. 正在安装mysqlclient...[31m[1m错误[0m在安装[32mmysqlclient[0m时发生错误
  11. Error text: Collecting mysqlclient (from -r
  12. /var/folders/x4/6p57c76d173_b99bb3rtc2q40000gn/T/pipenv-rva1k23w-requirements/pipenv-xzl65j4d-requirement.txt (line 1))
  13. 错误文本-r
  14. /var/folders/x4/6p57c76d173_b99bb3rtc2q40000gn/T/pipenv-rva1k23w-requirements/pipenv-xzl65j4d-requirement.txt (第1行)收集mysqlclient
  15. Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  16. 正在使用缓存的mysqlclient-2.1.1.tar.gz88 kB
  17. Installing build dependencies: started
  18. 安装构建依赖项已启动
  19. Installing build dependencies: finished with status 'done'
  20. 安装构建依赖项已完成状态为完成
  21. Getting requirements to build wheel: started
  22. 获取构建轮的要求已启动
  23. Getting requirements to build wheel: finished with status 'done'
  24. 获取构建轮的要求已完成状态为完成
  25. Preparing metadata (pyproject.toml): started
  26. 准备元数据pyproject.toml):已启动
  27. Preparing metadata (pyproject.toml): finished with status 'done'
  28. 准备元数据pyproject.toml):已完成状态为完成
  29. Building wheels for collected packages: mysqlclient
  30. 为收集的包构建轮mysqlclient
  31. Building wheel for mysqlclient (pyproject.toml): started
  32. mysqlclientpyproject.toml构建轮已启动
  33. Building wheel for mysqlclient (pyproject.toml): finished with status 'error'
  34. 构建mysqlclientpyproject.toml的轮已完成状态为错误
  35. Failed to build mysqlclient
  36. 构建mysqlclient失败
  37. [36m error: subprocess-exited-with-error
  38. × Building wheel for mysqlclient (pyproject.toml) did not run successfully.
  39. exit code: 1
  40. ╰─> [45 lines of output]
  41. mysql_config --version
  42. ['8.0.33']
  43. mysql_config --libs
  44. ['-L/opt/homebrew/Cellar/mysql/8.0.33/lib', '-lmysqlclient', '-lzlib', '-lzstd', '-L/opt/homebrew/opt/openssl@1.1/lib', '-lssl',
  45. '-lcrypto', '-lresolv']
  46. mysql_config --cflags
  47. ['-I/opt/homebrew/Cellar/mysql/8.0.33/include/mysql']
  48. ext_options:
  49. library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/lib', '/opt/homebrew/opt/openssl@1.1/lib']
  50. libraries: ['mysqlclient', 'zlib', 'resolv']
  51. extra_compile_args: ['-std=c99']
  52. extra_link_args: []
  53. include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/include/mysql']
  54. extra_objects: []
  55. define_macros: [('version_info', '(2,1,1,'final',0)'), ('__version__', '2.1.1')]
  56. running bdist_wheel
  57. running build
  58. running build_py
  59. creating build
  60. creating build/lib.macosx-10.9-universal2-cpython-311
  61. creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  62. copying MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  63. copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  64. copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  65. copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  66. copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  67. copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  68. copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
  69. creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
  70. copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
  71. copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-311/
  72. <details>
  73. <summary>英文:</summary>
  74. I have been troubleshooting this problem for the past 3 days, tried every method in stack and no luck, I am relatively new to Django and python so any suggestions will be greatly appreciated.
  75. so I have been having a problem with installing mysqlclient through &quot;pipenv install mysqlclient&quot;
  76. returning: `ERROR: Failed building wheel for mysqlclient`
  77. full summary:

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing mysqlclient...
Resolving mysqlclient...
Installing...
⠸ Installing mysqlclient...[31m[1mError: [0m An error occurred while installing [32mmysqlclient[0m!
Error text: Collecting mysqlclient (from -r
/var/folders/x4/6p57c76d173_b99bb3rtc2q40000gn/T/pipenv-rva1k23w-requirements/pipenv-xzl65j4d-requirement.txt (line 1))
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (pyproject.toml): started
Building wheel for mysqlclient (pyproject.toml): finished with status 'error'
Failed to build mysqlclient

[36m error: subprocess-exited-with-error

× Building wheel for mysqlclient (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [45 lines of output]
mysql_config --version
['8.0.33']
mysql_config --libs
['-L/opt/homebrew/Cellar/mysql/8.0.33/lib', '-lmysqlclient', '-lzlib', '-lzstd', '-L/opt/homebrew/opt/openssl@1.1/lib', '-lssl',
'-lcrypto', '-lresolv']
mysql_config --cflags
['-I/opt/homebrew/Cellar/mysql/8.0.33/include/mysql']
ext_options:
library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/lib', '/opt/homebrew/opt/openssl@1.1/lib']
libraries: ['mysqlclient', 'zlib', 'resolv']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/include/mysql']
extra_objects: []
define_macros: [('version_info', "(2,1,1,'final',0)"), ('version', '2.1.1')]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-311
creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
warning: build_py: byte-compiling is disabled, skipping.

  1. running build_ext
  2. building &#39;MySQLdb._mysql&#39; extension
  3. creating build/temp.macosx-10.9-universal2-cpython-311
  4. creating build/temp.macosx-10.9-universal2-cpython-311/MySQLdb
  5. clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g

-Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/opt/homebrew/Cellar/mysql/8.0.33/include/mysql
-I/Users/sonaallaibrahim/Desktop/storefront/my-test-env/include -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c
MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-311/MySQLdb/_mysql.o -std=c99
clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-cpython-311/MySQLdb/_mysql.o
-L/opt/homebrew/Cellar/mysql/8.0.33/lib -L/opt/homebrew/opt/openssl@1.1/lib -lmysqlclient -lzlib -lresolv -o
build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/_mysql.cpython-311-darwin.so
ld: library not found for -lzlib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
[0m
✘ Installation Failed

  1. am using python 3.11
  2. running on MacOS Ventura 13.3.1 M1 chip
  3. as I said any suggestions will help a lot
  4. tried uninstalling and reinstalling wheel
  5. tried uninstalling and reinstalling mysql
  6. tried unlinking mysql and link it back
  7. tried brew mysql connector
  8. tried brew mysql-client
  9. </details>
  10. # 答案1
  11. **得分**: 1
  12. 错误消息显示 `zlib` 未找到。这意味着要么库未安装,要么 Python 无法找到它。因此,首先要做的是安装该库。
  13. ```shell
  14. brew install zlib

接下来,我们需要为 Python 设置一些环境变量,以便它能够在正确的文件夹中查找库。设置以下环境变量(或将它们添加到您的 .bashrc 文件中)。

  1. export LDFLAGS="-L/usr/local/opt/zlib/lib"
  2. export CPPFLAGS="-I/usr/local/opt/zlib/include"

zlib 的实际路径可能会有所不同(在此情况下为 /usr/local/opt/zlib)。您可以通过执行以下命令获取您机器上的路径:brew --prefix zlib

英文:

The error message says zlib is not found. It means either the library is not installed, or python is not able to find it. So the first thing to do is to install the library.

  1. brew install zlib

Next, we need to set a couple of env variables for Python to look for the libraries in the right folder. Set the following env variables (or add them to your .bashrc)

  1. export LDFLAGS=&quot;-L/usr/local/opt/zlib/lib&quot;
  2. export CPPFLAGS=&quot;-I/usr/local/opt/zlib/include&quot;

The actual path for zlib might vary (its /usr/local/opt/zlib in this case. The path in your machine can be obtained by doing: brew --prefix zlib

huangapple
  • 本文由 发表于 2023年5月11日 19:45:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76227295.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定