简体   繁体   中英

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:

Command: 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)

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.

The solution is:

  1. run the PyCharm from the terminal with this command:

    /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 ),

  3. Close the program and re-open

  4. Now it should have all the packages installed properly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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