Error in installing MySQL pyhton on MAC
Today, I reported an error when installing MySQL Python
on MAC
, searched the network and said that there was a problem with the MySQL config
path, but it didn’t work
Solution
The initial problems were:
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-NknW3b/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-NknW3b/MySQL-python/
After searching, I found that brew install mysql-connector-c
, install brew install mysql-connector-c
,
reinstall MySQL Python
, and found that an error was still reported, but the error information changed:
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-u39xuY/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jy/7ybw8dpj71n9yhk_xj5jttxc0000gn/T/pip-install-u39xuY/MySQL-python/
I searched the Internet, but the solutions were wrong. Finally, I found that there was a configuration problem with mysql-connector-c
, so I modified the file
/usr/local/Cellar/mysql-connector-c/6.1.11/bin/mysql_config
:
cd /usr/local/Cellar/mysql-connector-c/6.1.11/bin/
cp mysql_config mysql_config.bak
sudo vim mysql_config
# Create options
libs="-L$pkglibdir"
# libs="$libs -l "
libs="$libs -lmysqlclient -lssl -lcrypto "
Then reinstall pip install MySQL-python
, Done!
Similar Posts:
- Error in Python compilation on MAC no module named mysqldb
- python mac install MySQLdb ModuleNotFoundError No module named ‘ConfigParser’
- [Solved] Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-9enuqi/My…
- CentOS 7: How to Solve Mysqlclient Install Error
- Mac version PIP install — upgrade PIP update version error
- Error in installing MySQL Python on MAC [Solved]
- EnvironmentError: mysql_config not found
- [Solved] Python import module error: importerror: no module named mysql.connector
- [How to Solve] ImportError: No module named MySQLdb
- How to Solve Django Error: No module named ‘MySQLdb’