[python setup.py egg_info错误mysqlclient

问题描述 投票:0回答:1

我刚刚开始使用Django学习Python,每次尝试使用Pycharm在终端中运行以下命令时,我似乎都被困在同一地方3天(是的,我使用的是Mac),我得到了出现以下错误:

命令:pip install mysqlclient

错误:

Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-c7mudszc/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-c7mudszc/mysqlclient/setup_posix.py", line 44, in get_config
(venv) Mervins-MacBook-Pro:untitled mervinkobola$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-w_jamo3b/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-w_jamo3b/mysqlclient/setup_posix.py", line 44, in get_config
(venv) Mervins-MacBook-Pro:untitled mervinkobola$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/

[请帮助我了解发生了什么以及如何解决。首先,我似乎无法运行以下命令:

python manage.py migration(因为我还没有安装mysqlclient)

谢谢您的帮助。

python django macos mysql-python
1个回答
3
投票

有时在mysql_config中设置了变量Terminal,但在PyCharm中未设置,因此这就是为什么出现此错误的原因。

解决方案是:

  1. 使用以下命令从终端运行PyCharm

    /Applications/PyCharm\ CE.app/Contents/MacOS/pycharm

  2. 之后(在PyCharm中)安装所需的软件包(可能在requirements.txt中,例如mysqlclient),

  3. [Close程序和re-open

  4. 现在应该已经正确安装了所有软件包

热门问题
推荐问题
最新问题