0
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 1 year has passed since last update.

mysqlclientのimportエラー(import MySQLdb, ImportError)

Last updated at Posted at 2023-01-13

mysqlclientで以下のエラーが発生しました。

(開発環境)
macOS Big Sur (M1)
python 3.8.5
mysqlclient 2.1.1

main.py
import MySQLdb
Traceback (most recent call last):
  File "main.py", line 12, in <module>
    import MySQLdb 
  File "/Users/foo/opt/anaconda3/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <module>
    from . import _mysql
ImportError: dlopen(/Users/foo/opt/anaconda3/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Users/foo/opt/anaconda3/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so
  Expected in: flat namespace
 in /Users/foo/opt/anaconda3/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-darwin.so

・解決法
pythonのバージョンを3.8⇨3.10に上げたところ、エラーが解消しました。
下のGithubのイシューでも議論されていましたので参考にしてください。
https://github.com/PyMySQL/mysqlclient/issues/496

0
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
0
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?