I am trying to pip install
the MySQL-python
package, but I get an ImportError
.
Jans-MacBook-Pro:~ jan$ /Library/Framew
I was having the same problem. Turns out, I needed to install python3 devel on my centos. First, you need to search for the package that is compatible with your system.
yum search python3 | grep devel
Then, install the package as:
yum install -y python3-devel.x86_64
Then, install mysqlclient from pip
pip install mysqlclient
Kindly to see what is /usr/bin/python
pointing to
if it is pointing to python3 or higher
change to python2.7
This should solve the issue.
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem.
Then I recalled that I had manually changed the /usr/bin/python
from python2.7
to /usr/bin/python3.5
, which actually was causing the issue. Once I reverted
the same. It got solved.
MySQL-python is not supported on python3 instead of this you can use mysqlclient
If you are on fedora/centos/Red Hat
install following package
yum install python3-devel
pip install mysqlclient
Compatibility of Python 2/3 for configparser
can be solved simply by six
library
from six.moves import configparser
Try this solution which worked fine for me.
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient
or MySQL-Python
from global pip3
instead of virtualenv pip3
.
Then accessing the virtualenv
and successfully install mysqlclient
or MySQL-Python
.
I was getting the same error on Mac OS 10, Python 3.7.6 & Django 2.2.7. I want to use this opportunity to share what worked for me after trying out numerous solutions.
Steps
Installed Connector/Python 8.0.20 for Mac OS from link
Copy current dependencies into requirements.txt file, deactivated the current virtual env, and deleted it using;
create the file if not already created with; touch requirements.txt
copy dependency to file; python -m pip3 freeze > requirements.txt
deactivate and delete current virtual env; deactivate && rm -rf <virtual-env-name>
Created another virtual env and activated it using; python -m venv <virtual-env-name> && source <virtual-env-name>/bin/activate
Install previous dependencies using; python -m pip3 install -r requirements.txt