pip install mysql-python falla con EnvironmentError: mysql config not found
Este es el error que obtengo
(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
¿Qué puedo hacer para resolver esto?
18 answers
Parece que falta mysql_config en su sistema o el instalador no pudo encontrarlo. Asegúrese de que mysql_config esté realmente instalado.
Por ejemplo en Debian / Ubuntu debe instalar el paquete:
sudo apt-get install libmysqlclient-dev
Tal vez el mysql_config no está en su ruta, será el caso cuando compile usted mismo la suite mysql.
Actualización: Para las versiones recientes de debian/ubuntu (a partir de 2018) es
sudo apt install default-libmysqlclient-dev
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-04 16:05:33
Ejecutando Mac OSX Mountain Lion, simplemente ejecuté esto en terminal para arreglar:
export PATH=$PATH:/usr/local/mysql/bin
Esta es la solución más rápida que encontré - lo agrega a la ruta, pero creo que es mejor agregarlo permanentemente (es decir, agregarlo a /etc/paths
) si planea instalar MySQL-python en otro entorno.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-10 09:47:25
apt-get install libmysqlclient-dev python-dev
Parecía hacer el truco.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-04 06:51:35
Tal vez haya varias respuestas para el problema anterior, a continuación se muestra una solución agregada.
Para Ubuntu:
$ sudo apt update
$ sudo apt install python-dev
$ sudo apt install python-MySQLdb
Para CentOS:
$ yum install python-devel mysql-devel
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-15 10:27:24
Puede usar el conector MySQL / Python
Instalación a través de PyPip
pip install mysql-connector-python
Puede encontrar más información en el blog MySQL Connector/Python 1.0.5 beta announcement.
En Launchpad hay un buen ejemplo de cómo agregar, editar o eliminar datos con la biblioteca.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-11 12:05:19
Para usuarios de centos:
yum install -y mysql-devel python-devel python-setuptools
Entonces
pip install MySQL-python
Si esta solución no funciona , e imprime el error de compilación de gcc como:_mysql.c:29:20: error: Python.h: No such file or directory
Necesita especificar la ruta de Python.h
, así:pip install --global-option=build_ext --global-option="-I/usr/include/python2.6" MySQL-python
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-04 07:51:20
Si está en MAC Instalar esto globalmente
brew install mysql
Luego exportar ruta como esta
export PATH=$PATH:/usr/local/mysql/bin
Finalmente globalmente o en tu venv
pip install MySQL-Python
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-14 09:59:36
Estaba tratando de instalar mysql-python
en una instancia de Amazon EC2 Linux y tuve que instalar estos :
yum install mysql mysql-devel mysql-common mysql-libs gcc
Pero entonces obtuve este error:
_mysql.c:29:20: fatal error: Python.h: No such file or directory
Así que instalé:
yum install python-devel
Y eso hizo el truco.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-07-25 21:45:35
OSX Mavericks
Debido a los cambios dentro de las herramientas de desarrollo de osx mavericks y xcode, puede obtener el error en la instalación
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
Por lo tanto use:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mysql-python
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-19 18:36:00
Para cualquiera que esté usando MariaDB en lugar de MySQL, la solución es instalar el paquete libmariadbclient-dev
y crear un enlace simbólico al archivo de configuración con el nombre correcto.
Por ejemplo esto funcionó para mí:
ln -s /usr/bin/mariadb_config /usr/bin/mysql_config
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-06-19 12:44:58
Intenta sudo apt-get build-dep python-mysqldb
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-06-24 20:15:37
Para mariadb install lib mariadb client-dev en lugar de libmysqlclient-dev
sudo apt-get install libmariadbclient-dev
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-14 07:30:04
A veces el error depende de la causa real. tuvimos un caso en el que mysql-python fue instalado a través del paquete debian python-mysqldb.
Un desarrollador que no sabía esto, accidentalmente ejecutó pip uninstall mysql-python
y luego no pudo recuperarse con pip install mysql-python
dando el error anterior.
pip uninstall mysql-python
había destruido el contenido del paquete debian, y por supuesto pip install mysql-python
falló porque el paquete debian no necesitaba ningún archivo de desarrollo.
La solución correcta en ese caso fue apt-get install --reinstall python-mysqldb
que restauró mysql-python a su estado original.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-29 14:31:28
Primero debes instalar el mysql
:
yum install python-devel mysql-community-devel -y
Entonces puedes instalar mysqlclient
:
pip install mysqlclient
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-29 01:11:43
Tuvo un problema similar al intentar instalar en OS X Server 10.6.8. Esto es lo que tenía que hacer. Usando:
MySQL-python 1.2. 4b4 (fuente) MySQL-5.6.19 (instalador binario) Python 2.7 (instalador binario) NOTA: Instalación en virtualenv...
Descomprimir el código fuente, abrir 'distribute_setup.py' y edite DEFAULT_VERSION para usar la última versión de distribute tools, así:
DEFAULT_VERSION = "0.6.49"
Guardar. Abra el sitio.cfg' archivo y descomentar la ruta a mysql_config para que se vea algo como (referencia a su ruta propia a mysql_config):
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
mysql_config = /usr/local/mysql/bin/mysql_config
Ahora clean, build y make no fallarán con el error 'mysql_config' not found. Espero que esto ayude a alguien más tratando de hacer uso de sus viejos xserves: -)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-05 15:20:16
Tu camino sudo no conoce tu camino local... vaya al modo superusuario, agregue la ruta e instálela desde allí.
sudo su
export PATH=$PATH:/usr/local/mysql/bin/
pip install mysql-python
exit
Y estás listo y funcionando en OSX. Ahora tienes un python global actualizado.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-17 17:07:20
Si instala MySQL-python en su env virtual, debe verificar la versión pip, si la versión es anterior a 9.0.1, actualícela
pip install --upgrade pip
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-21 11:30:12
Tuve el mismo problema en el Terraform:light container. Se basa en Alpine.
Allí tienes que instalar mariadb-dev con:
apk add mariadb-dev
Pero esa no es suficiente porque también se pierden todas las demás dependencias:
apk add python2 py2-pip gcc python2-dev musl-dev
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-11 10:34:46