I use macports and I have successfully install mysql5 using macports, and my python also managed by macports. Currently I am trying to do pip install mysql-python on my virtualenv but I am getting an error which says, mysql_config not found:
~/code]$pip install mysql-python
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, 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
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, 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
I read many google examples but more I read helped me to confuse myself further.
Looks like macport have had a issue but it has been closed for while.. http://trac.macports.org/ticket/6982
MacPort creates a symbolic link mysql_config5 in /opt/local/bin to /opt/local/lib/mysql5/bin/mysql_config. Create another link called mysql_config.
cd /opt/local/bin
sudo ln -s /opt/local/lib/mysql5/bin/mysql_config .
I seem to recall having to create a my.cnf too. By default Mac OSX uses all the defaults and doesn't create a my.cnf, create one /etc/my.cnf, it can be trivial.
Mine is just:
[mysqld]
bind-address = 0.0.0.0
port = 3306
mysql_config is an executable that it is in the libmysqlclient package so you need to install. On Deb systems you could install this using
sudo apt-get install libmysqlclient-dev
in RPM
RPM equivalent: sudo yum install mysql-devel
in mac maybe
Macports - port install mysql5 +server
Add /opt/local/lib/mysql5/bin/ to your command search path and then rerun the "pip install" command should solve the problem.
export PATH=/opt/local/lib/mysql55/bin/:$PATH
pip install mysql-python
I encountered the same issue, and solved it:
Install mysql. If you have installed it, ignore this step.
yum install mysql-devel
If you encountered error like Python.h: No such file or directory,
run yum -y install python-devel
Related
Everytime I execute my python code, it gives me the above ModuleNotFound error when I execute with python3. With python, it gives me an ImportError.
I have updated setuptools using pip install --upgrade setuptools.
I have also tried multiple commands such as: pip install mysqlclient, pip install MySQL-python, pip install pymysql.
I have tried these commands with pip3 as well (Not sure if it makes a difference).
Everytime I try these commands, it gives me the following error:
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/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 51, in get_config
libs = mysql_config("libs")
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 29, 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/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient
How do I fix this? I am using a macOS High Sierra. I have gone through solutions for similar problems on ubuntu/debian systems and have to tried to apply it here. None of that works on a mac. Also, i already have mysql installed and it works perfectly. It is constantly running on my system.
you should download a tar named as Mysql-python-1.2.4b4.tar.gz, and unzip it, cd to the dir and update the file site.cfg: # mysql_config = /usr/local/mysql/bin/mysql_config to mysql_config = /usr/local/mysql/bin/mysql_config
and then python setup.py install, after you installed the mysql-python,then you can not get the error.
I am trying to install mysqlclient to my Python 3.6. Originally what i want to install is MySQLdb, however it was saying that MySQLdb does not work with Python 3 (still?). So i switch to mysqlclient.
pip3 install mysqlclient
However, it was given this error:
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup.py", line 18, in <module>
metadata, options = get_config()
File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 60, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 60, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 13, in dequote
raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")
Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?
Can I know what should i do to solve this issue?
It's a bug since November 2017.
I had the same error and that's what helped:
Make changes to mysql_config file in mysqlclient-python or mysql-connector-c or libmysqlclient (depending on what you are using)
Change
# on macOS, on or about line 112:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
to:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
Add following to the end of your .bash_profile how to do that:
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
Run pip install mysqlclient, that should work now.
For more info check this link, look at the "Note about bug of MySQL Connector/C on macOS" section.
I'm trying to install MySQLdb for Python on Mac OS.
When I digit pip install MySQL-python shell returns to this:
Collecting MySQL-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/9h/2lp9kx993ygbrfk1lxr0sz500000gq/T/pip-install-7xyyBe/MySQL-python/setup.py", line 17, in
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/9h/2lp9kx993ygbrfk1lxr0sz500000gq/T/pip-install-7xyyBe/MySQL-python/
What can I do? I searched everywhere but I couldn't find an answer.
(I had installed Python 2.7)
I fixed the error. If anyone have this error just follow these steps:
First of all install mysql connector
brew install mysql-connector-c
You have to modify lines in mysql_config (this is an alias)
vim /usr/local/bin/mysql_config
(I sincerely consider to open mysql_config with a file editor, you can find the
exact folder here)
/usr/local/Cellar/mysql-connector-c/6.1.11/bin/
Replace these lines.
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
should be:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
Set environment variable
brew info openssl
it would tell what’s needed
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
Then you can install MySQL
pip install MySQL-python
You can test if MySQL is installed with this:
python -c "import MySQLdb"
Hope this works also for you!
Trying to follow a Django tutorial but I cannot install mysqlclient.
The tutorial claims that I can do so with the following command:
pip install mysqlclient
but this generates this error:
Collecting mysqlclient Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-rrolctwh/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-rrolctwh/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-rrolctwh/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 /tmp/pip-build-rrolctwh/mysqlclient/
I have the most up-to-date pip and virtualenv installed.
I would like to be able to install mysqlclient so that I may continue with the tutorial.
You should also install the mysql and python development headers and libraries:
https://github.com/PyMySQL/mysqlclient-python#prerequisites
I was facing the same problems, but following the instructions in the Official mysqlclient documentation fixed it for me
but just to clarify I was running python 3.5 from a virtual environment
and after installing the prerequisites, it all worked fine
The following solved it for me :
You may need to install the Python 3 and MySQL development headers and libraries like so:
$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential # Debian / Ubuntu
% sudo yum install python3-devel mysql-devel # Red Hat / CentOS
Then you can install mysqlclient via pip now:
$ pip install mysqlclient
Source : https://github.com/PyMySQL/mysqlclient#prerequisites
I had also similar issue on Centos 6, where there was a problem with mysql migration to maria, I had some conflicts, but finally I installed:
yum list installed |grep MariaDB
MariaDB-client.x86_64 10.2.7-1.el6 #bull
MariaDB-common.x86_64 10.2.7-1.el6 #bull
MariaDB-compat.x86_64 10.2.7-1.el6 #bull
MariaDB-devel.x86_64 10.2.7-1.el6 #bull
MariaDB-server.x86_64 10.2.7-1.el6 #bull
And the issue was resolved.
I have a EC2 instance created on AWS and use PuTTY to connect to it.
I'm unable to install MySQL-python using python pip command as follows:
pip install MySQL-python(via root privileges)
Here is the console output of the error
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-JGbAEI/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-JGbAEI/MySQL-python/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-JGbAEI/MySQL-python/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 /tmp/pip-build-JGbAEI/MySQL-python
However I'm able to install other packages using pip
Please Guide.
mysql_config is available after installation of the following package on Amazon Linux:
sudo yum install -y mysql-devel
It looks like mysql_config is missing, so make sure mysql_config is really installed.
For example on Debian/Ubuntu you must install the package:
sudo apt-get install libmysqlclient-dev