This is the error I get
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
Running setup.py egg_info for package mysql-python
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, 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 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, 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 24, 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
Storing complete log in /home/zjm1126/.pip/pip.log
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, 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 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, 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 24, 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
Storing complete log in /home/zjm1126/.pip/pip.log
What can I do to resolve this?
It seems mysql_config is missing on your system or the installer could not find it. Be sure mysql_config is really installed.
sudo apt-get install libmysqlclient-dev
In Mac OS, I simply ran this in terminal to fix:
export PATH=$PATH:/usr/local/mysql/bin
apt-get install libmysqlclient-dev python-dev
似乎成功了。
There maybe various answers for the above issue, below is a aggregated solution.
$ sudo apt update
$ sudo apt install python-dev
$ sudo apt install python-MySQLdb
If you are on MAC Install this globally
brew install mysql
then export path like this
export PATH=$PATH:/usr/local/mysql/bin
Than globally or in your venv whatever you like
pip install MySQL-Python
Note: globally for python3 as Mac can have both python2 & 3
pip3 install MySQL-Python
You can use the MySQL Connector\/Python
pip install mysql-connector-python
For centos<\/strong> users:
_mysql.c:29:20: error: Python.h: No such file or directory<\/code>
pip install --global-option=build_ext --global-option="-I\/usr\/include\/python2.6" MySQL-python<\/code>
I was trying to install mysql-python<\/code> on an Amazon EC2 Linux instance and I had to install these :
yum install mysql mysql-devel mysql-common mysql-libs gcc
For anyone that is using MariaDB instead of MySQL, the solution is to install the libmariadbclient-dev<\/code> package and create a symbolic link to the config file with the correct name.
ln -s /usr/bin/mariadb_config /usr/bin/mysql_config
this works for me
yum install python-devel mysql-devel
尝试sudo apt-get build-dep python-mysqldb<\/code>
"
Due to changes within osx mavericks & xcode development tools you may get the error on installation
对于 mariadb 安装lib mariadb client-dev而不是libmysqlclient-dev
sudo apt-get install libmariadbclient-dev
You should install the mysql<\/code> first:
yum install python-devel mysql-community-devel -y
I had the same problem in the Terraform:light container. It is based on Alpine.
There you have to install mariadb-dev with:
apk add mariadb-dev
But that one is not enough because also all the other dependencies are missed:
apk add python2 py2-pip gcc python2-dev musl-dev
sometimes the error depends on the actual cause. we had a case where mysql-python was installed through the python-mysqldb debian package.
Sequence to be followed.
pip install mysqlclient
sudo apt-get install python3-dev libmysqlclient-dev
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Had a similar issue trying to install on OS X Server 10.6.8. Here's what I had to do. Using:
DEFAULT_VERSION = "0.6.49"
Your sudo path does not know about your local path... go into superuser mode, add the path, and install it from there.
sudo su
export PATH=$PATH:/usr/local/mysql/bin/
pip install mysql-python
exit
如果您在虚拟环境中安装 MySQL-python,您应该检查 pip 版本,如果版本低于 9.0.1,请更新它
pip install --upgrade pip
On Mac:
brew install mysql-client
write on 27 Aug, 2021
It seems like in the higher version of mysql, they delete the my_config.h<\/code> files but change to the
mysql.h<\/code> .
cd /usr/local/include/mysql
cp mysql.h my_config.h
在 MacOS Mojave 上,mysql_config 位于 \/usr\/local\/bin\/ 而不是 \/usr\/local\/mysql\/bin 如上所述,因此无需向路径添加任何内容。
"In my case my database is running on container and my flask app is running on another container when i tried updating code app got broke with error
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-bya8e734/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-build-bya8e734/mysqlclient/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-build-bya8e734/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
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.