[英]Unable to install mysqlclient in django
我在 django 框架中使用最新的 python 版本 3.11,为此我需要安装 mysqlclient。 但是我尝试安装时出现错误
pip install mysqlclient
Output 这样的错误:
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools
/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
error: subprocess-exited-with-error
× Running setup.py install for mysqlclient did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
running install
C:\Users\dsema\PycharmProjects\stock\venv\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated.
Use build and pip and other standards-based tools.
warnings.warn(
running build_ext
building 'MySQLdb._mysql' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools
/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> mysqlclient
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
任何想法都可以解决吗?
你显然在 Windows,所以你想确保pip
尝试使用mysqlclient
的二进制包,而不是尝试从头开始构建一个:
pip install mysqlclient --only-binary=mysqlclient
但是,这可能会安装旧版本的mysqlclient
,因为您正在使用的 32 位 Python 3.11没有二进制包。 如果您的机器能够运行 64 位版本,我强烈建议您改用它,因为在不久的将来,32 位支持可能会越来越少。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.