install python MySQLdb to python3 not python
14,106
Solution 1
As far as I know, it's not ported to python3 yet.
Solution 2
1- You can use this command
sudo apt-get install python3-mysqldb
It worked for me.
2- also you can install pip install PyMySQL
.
Then add lines to __init__.py
file
# __init__.py file
import pymysql
pymysql.install_as_MySQLdb()
Solution 3
MySQLdb is not yet Python3 compatible, but oursql, a Python-MySQL driver, is.
Solution 4
you can use this:
https://github.com/davispuh/MySQL-for-Python-3/wiki/Install-on-Linux
It worked for me.
Solution 5
How to install MySQLdb for Python2
sudo apt-get install python-mysqldb
How to install MySQLdb for Python3
sudo apt-get install python3-mysqldb
Author by
user670186
Updated on July 23, 2022Comments
-
user670186 almost 2 years
i have Ubuntu and installed python3 since my script is written in it. Since I use MYSQL with MySQLdb, I installed
apt-get install python-mysqldb
however this installed MySQLdb to Python (which is 2.6 on Ubuntu) and not to Python3.
- How can I install MySQLdb for Python3
- Should I use it at all or switch to PyMSQL
Sorry, I have just started working with Python today...
-
Patrick Da Silva over 5 yearsFor me too! Thanks!
-
Budi Mulyo over 3 yearsit's works to install but can't used, not listed in modul after installed successfully