Problems and solutions when asked for MySQL db in Python 3

problem

Pip install MySQL-Python for installing MySQLdb is not compatible with Python3.

import ConfigParser

From Python3, it is ↓ (all lowercase letters), so ModuleNotFoundError: No module named'ConfigParser' causes an error.

import configparser

Solution

With pip install mysqlclient.

Note that ↑ will fail if python-devel is not included. ..

yum update -y
yum install -y python-devel # /usr/include/python2.7
yum install -y python3-devel # /usr/include/python3.7m
yum install -y python38-devel # /usr/include/python3.8

↓ is also recommended

yum install -y gcc mysql-devel mysql-libs # /lib64/mysql/libmysqlclient.so.18 enters

** When running on Lambda, be sure to see Running mysqlclient on Lambda in the reference section **

reference

Recommended Posts

Problems and solutions when asked for MySQL db in Python 3
Problems and countermeasures for Otsu's binarization overflow in Python
[Tips] Problems and solutions in the development of python + kivy
[Introduction for beginners] Working with MySQL in Python
Combining problems in Python
Write Python in MySQL
Rock-paper-scissors poi in Python for beginners (answers and explanations)
Preferences for playing Wave in Python PyAudio and PortAudio
Recursively search for files and directories in Python and output
Problems and solutions for using the remote debugging environment for Linux apps in Visual Studio 2017
Tips for developing apps with Azure Cosmos DB in Python
Search for strings in Python
Techniques for sorting in Python
Tips for coding short and easy to read in Python
(For myself) Flask_6 (Open db from python, Mysql basic (phpMyAdmin))
Useful tricks related to list and for statements in Python
Attention when os.mkdir in Python
Stack and Queue in Python
Unittest and CI in Python
Solve optimization problems in Python
About "for _ in range ():" in python
Things to watch out for when using default arguments in Python
Precautions when passing def to sorted and groupby functions in Python? ??
Create a CGH for branching a laser in Python (laser and SLM required)
Check for memory leaks in Python
MIDI packages in Python midi and pretty_midi
Difference between list () and [] in Python
Difference between == and is in python
View photos in Python and html
Sorting algorithm and implementation in Python
Python and DB: Understanding DBI cursors
Behavior when listing in Python heapq
Manipulate files and folders in Python
About dtypes in Python and Cython
Assignments and changes in Python objects
Check and move directories in Python
Hashing data in R and Python
How to use Mysql in python
Function synthesis and application in Python
Export and output files in Python
Load Mac Python import MySQL db
Run unittests in Python (for beginners)
Reverse Hiragana and Katakana in Python2.7
Reading and writing text in Python
[GUI in Python] PyQt5-Menu and Toolbar-
When using regular expressions in Python
When writing a program in Python
Create and read messagepacks in Python
(For myself) Flask_AWS_1 (Install PHP, MySQL, phpMyAdmin, Python in AWS virtual environment)
UnionFind in python (enhanced version: strings and tuples are allowed for elements)
[AWS] Problem avoidance memo when installing awscli and boto3 in Python 2.7 environment
A useful note when using Python for the first time in a while
Build a lightweight server in Python and listen for Scratch 2 HTTP extensions
When specifying multiple keys in python sort
Notes using cChardet and python3-chardet in Python 3.3.1.
Modules and packages in Python are "namespaces"
INSERT into MySQL with Python [For beginners]
Avoid nested loops in PHP and Python
Differences between Ruby and Python in scope
[Python] Use and and or when creating variables
AM modulation and demodulation in Python Part 2