简体   繁体   English

python setup.py egg_info错误mysqlclient

[英]python setup.py egg_info error mysqlclient

I just started learning Python using Django and I just seemed to be stuck at the same place for 3 days, every time I try to run the following command in my terminal using Pycharm (Yep, I am using a Mac) I get the below error: 我刚刚开始使用Django学习Python,每次似乎都被困在同一地方3天,每次我尝试使用Pycharm在终端中运行以下命令时(是的,我使用的是Mac),我都会收到以下错误消息:

Command: pip install mysqlclient 命令:pip install mysqlclient

Error: 错误:

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/

Please help me understand whats going on and how I can solve it. 请帮助我了解发生了什么以及如何解决。 Above all I can't seem to run the following : 首先,我似乎无法运行以下命令:

python manage.py migrate (as I haven't installed mysqlclient) python manage.py migration(因为我还没有安装mysqlclient)

Thank you in advance for your assistance. 预先感谢您的协助。

Sometimes the variable mysql_config is set in the Terminal but not in PyCharm so this is why you're getting this error. 有时在Terminal设置了变量mysql_config ,但在PyCharm未设置,因此这就是为什么您会收到此错误的原因。

The solution is: 解决方案是:

  1. run the PyCharm from the terminal with this command: 使用以下命令从终端运行PyCharm

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

  2. After that (in PyCharm ) install the packages you need (probably they are in your requirements.txt , for example the mysqlclient ), 之后(在PyCharm )安装所需的软件包(可能它们在您的requirements.txt ,例如mysqlclient ),

  3. Close the program and re-open Close程序,然后re-open

  4. Now it should have all the packages installed properly 现在应该已经正确安装了所有软件包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM