Installing MySQL Python on Mac OS X
Another option is to use pymysql it is a pure Python client connection to MySQL so you don't have to mess around with compiling, a good exercise, but it can be frustrating if you are just trying to get something done. pymysql follows the same API as MySQLdb, it can essentially be used as a drop in replacement.
Also, it used to be that MySQLdb, did not work with Python 3, but this may have changed, pymysql didn't have that problem which also induced me to switch, this may have changed though. pymysql can be slower than MySQLdb but you'll have to see if you notice that, it is also under a different license (MIT for pymysql, GPL for MySQLdb)
pip install MySQL-python
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!
MySQL-python install Mac
install mysql connector using homebrew brew install mysql-connector-c
then install mysql-python using pip pip install mysql-python
or try PyMySQL its a pure python client library, you can install using pip install PyMySQL
and upgrade setuptools
. pip install --upgrade setuptools
.
Mac pip install mysql-python unsuccessful
Please, try:
CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install -r requirements.txt
If it does not work:
First install mysql-connector-c
brew install mysql-connector-c
pip install MySQL-python
If you are using Windows:
https://dev.mysql.com/downloads/connector/c/
You can also check what happend when you try install it with pip3.
UPDATE:
If you have Linux:
Please open the /usr/local/bin/mysql_config
.
And then:
#Create options
Libs = "-L $ pkglibdir "
Libs = " $ libs -l"
replace with:
#Create options
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"
Save it and reinstall mysql-python
.
pip uninstall mysql-python
pip install mysql-python
For Mac:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysql-python
should be helpful.
Can't install mysql-python with pip on MacOS 10.12.4
Solved with this
brew install mysql
pip install MySQL-python
Related Topics
Convert a List of Tuples to a List of Lists
Segmenting License Plate Characters
Define a Method Outside of Class Definition
Import Script from a Parent Directory
Open Cv Error: (-215) Scn == 3 || Scn == 4 in Function Cvtcolor
Python: Slicing a Multi-Dimensional Array
Getting List of Pixel Values from Pil
Pandas: Resample Timeseries with Groupby
How to Use a Multiprocessing Queue in a Function Called by Pool.Imap
How to Handle an Asymptote/Discontinuity with Matplotlib
Will Ordereddict Become Redundant in Python 3.7
How to Get Value from Form Field in Django Framework
Zip with List Output Instead of Tuple