gpt4 book ai didi

python - 如何在python中安装mysqlclient?

转载 作者:行者123 更新时间:2023-12-03 08:53:07 28 4
gpt4 key购买 nike

我是 Python 新手,有 Java 和 JS 背景,
我已经在本地计算机上安装了 Python 和 Pip,
我正在尝试使用 MySQL 来学习 Django,
但我无法使用 pip 安装 mysqlclient
我使用以下命令来执行此操作 -

pip install mysqlclient

出现以下错误 -

Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

屏幕截图 -

enter image description here

最佳答案

mysqlclient 需要额外的 c 库。
对于 Linux (Debian):
$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
对于 Mac:
$brew安装mysql
进一步阅读home page

关于python - 如何在python中安装mysqlclient?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57643579/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com