1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python3でMySQLdbを求められたときの問題と解決

Last updated at Posted at 2020-09-15

問題点

MySQLdb を入れるための pip install MySQL-Python はPython3に対応できてない。

※↓を実行しようとするが、

import ConfigParser

Python3から、↓(全て小文字)になっているためModuleNotFoundError: No module named 'ConfigParser'でエラーになる。

import configparser

解決

pip install mysqlclient で。

python-devel が入っていないと↑は失敗するので注意。。
/usr/include/pythonX.X 内に Python.h がないとダメ。

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

↓も実行しておくの推奨

yum install -y gcc mysql-devel mysql-libs # /lib64/mysql/libmysqlclient.so.18 が入る

Lambda上で動かす場合、必ず参照項のLambda上でmysqlclientを動かすを見ること

参照

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?