I've read a few questions on here that people are having the same situation as me but no matter what method I tried, it just wouldn't work!
According to MySQL documentation, MySQL-coector-python-2.x.x.x should work with Python 3+. I've downloaded the RPM package and installed it inside my virtualenv. However, upon importing the library, I get the error, "No module named MySQL".
Checking to see if I've installed the package:
(virtual)[centos ~]$ rpm -ql mysql-coector-python-2.1.3-1.el6.x86_64.rpm
package mysql-coector-python-2.1.3-1.el6.x86_64.rpm is not installed
Attempting to install the package:
(virtual)[centos ~]$ sudo rpm -i ~/Documents/python/mysql-coector-python-2.1.3-1.el6.x86_64.rpm
[sudo] password for <useame>:
waing: /home/knguyen/Documents/python/mysql-coector-python-2.1.3-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
package mysql-coector-python-2.1.3-1.el6.x86_64 is already installed
This works on Python2.6:
[centos ~]$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> import mysql.coector
>>>
Doesn't on Python3.5:
[centos ~]$ python3.5
Python 3.5.1 (default, Jan 13 2016, 17:43:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.coector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'mysql'
>>>
Verified the package through MySQL documentation:
(virtual)[centos]$ python
Python 3.5.1 (default, Jan 13 2016, 17:43:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from distutils.sysconfig import get_python_lib
>>> print (get_python_lib ())
/home/<useame>/Documents/redhat-server/python_project/virtual/lib/python3.5/site-packages
>>>
>>> import mysql.coector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'mysql'
>>>
Making sure that python3.5 is in the same directory as MySQL.coector
(virtual)[centos]$ which python3.5
~/Documents/redhat-server/python_project/virtual/bin/python3.5
What am I doing wrong?
