0

I am fairly new to python and I am trying to write a script that would read and write to a mysql table. I have installed mysql-connector on python3 and I got the script working yesterday. It successfully read and wrote data to mysql. When I ran it today, this error came up. ModuleNotFoundError: No module named 'mysql'

I already checked the following things:

  • mysql-connector is installed
  • I don't have any user-defined module named mysql
  • not running on virtualenv

Does someone have any idea on what is happening?

uji
  • 1,603
  • 3
  • 12
  • 12
  • Ensure `mysql` is installed to the correct Python3. If you do `python3 -m pip freeze` you should see what packages are installed -- if you need to install it, simply do `python3 -m pip install mysql`. – felipe Feb 19 '20 at 01:58
  • I only have the one python3 installed. ```python3 -m pip freeze``` gives me this: mysql-connector-python==8.0.19 @Felipe. So I believe I have it installed properly? – uji Feb 19 '20 at 02:19

1 Answers1

0

check if mysql-connector is installed: python -m pip freeze. It is probably not listed. You can install it with:

pip install mysql-connector

or

python -m pip install mysql-connector

chloeloe
  • 17
  • 3
  • please also see [import-error-no-module-named-mysql](https://stackoverflow.com/questions/32877671/importerror-no-module-named-mysql) – chloeloe Jan 12 '23 at 13:54