install python MySQLdb to python3 not python
NickName:user670186 Ask DateTime:2012-02-05T10:06:01

install python MySQLdb to python3 not python

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.

  1. How can I install MySQLdb for Python3
  2. Should I use it at all or switch to PyMSQL

Sorry, I have just started working with Python today...

Copyright Notice:Content Author:「user670186」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/9146320/install-python-mysqldb-to-python3-not-python

Answers
kgf3JfUtW 2018-10-26T06:42:24

How to install MySQLdb for Python2\n\nsudo apt-get install python-mysqldb\n\n\nHow to install MySQLdb for Python3\n\nsudo apt-get install python3-mysqldb\n",


Ludo Schmidt 2018-07-25T09:29:06

This was a success for me on linux (UBUNTU) and anaconda:\n\nsudo apt-get install libmysqlclient-dev\n( it get mysql_config )\n\nthen \n\npip3 install git+git://github.com/davispuh/MySQL-for-Python-3\n\nthat's it...\n\nMore info on https://github.com/davispuh/MySQL-for-Python-3/wiki/Install-on-Linux",


Aly Radwan 2017-11-10T09:47:03

1- You can use this command\nsudo apt-get install python3-mysqldb\nIt worked for me.\n2- also you can install pip install PyMySQL.\nThen add lines to __init__.py file\n# __init__.py file\n\nimport pymysql\npymysql.install_as_MySQLdb()\n",


unutbu 2012-02-05T03:06:18

MySQLdb is not yet Python3 compatible, but\noursql, a Python-MySQL driver, is.",


shadyabhi 2012-02-05T02:16:44

As far as I know, it's not ported to python3 yet. ",


Thamayron Alves 2015-11-02T00:10:36

you can use this:\n\nhttps://github.com/davispuh/MySQL-for-Python-3/wiki/Install-on-Linux\n\nIt worked for me.",


More about “install python MySQLdb to python3 not python” related questions

install python MySQLdb to python3 not python

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 i...

Show Detail

Cannot import MySQLdb in Python3, but Python2 works

I installed the module using sudo apt-get install python-mysqldb. Now, it works for Python 2, but not for Python 3. How may I get it working for Python 3? ubuntu:~$ which python /usr/bin/python

Show Detail

Error with MysqlDB python3 CentOS and _mysql Flask

I am trying to get my python3 flask app to work on Centos. At first I was getting this error: ImportError: this is MySQLdb version (1, 3, 10, 'final', 0), but _mysql is version (1, 2, 5, 'final',...

Show Detail

Unable to install mysqlclient in python3 virtualenv

I want to run django with MySQL and Python 3. I initialized virtual environment with virtualenv --no-site-packages -p python3 ./. Then I installed django and wheel using pip, so pip freeze gives ...

Show Detail

install mysqldb for python

i try to install mysqldb for python, i'm new to python, sorry before. when i typed "python setup.py install" on my prompt, this is the msg : Traceback (most recent call last): File "C:\Python26\...

Show Detail

In python3, after installing mysqlclient, dependancy for MySQLdb persists

I have shifted to python3 and trying to create my web application using django 1.11.1, i.e the latest version. I have virtualenv set up where I have installed all my requirements. As per django-d...

Show Detail

How to install Flask-mysqldb for Python?

I am new to Python and Python-Flask and have ran into an error. I am using Ubuntu 18.04.3 LTS and Python 2.7.15+ to build a python-flask web application. When installing flask-mysqldb I run into an

Show Detail

python3 install mysqlclient and get error :‘MYSQL_DEFAULT_AUTH’ undeclared

[root@bigdata01 mysqlclient-python-master]# python3 setup.py install /usr/local/python3/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_typ...

Show Detail

install python-mysqldb using python script

I am writing a python script for an application. The application needs python-mysqldb. In terminal, I can install it with apt-get or pip. How can I install using python script? I am using python 2.7.

Show Detail

How do I install and use MySQLdb for Python 3 on Windows 10?

My various searches seem to come up with very old posts or a mention of how to do this under cygwin. I had python 3.5 installed and then installed Anaconda3. I have python 3.5 (Cpython) installed...

Show Detail