Sort of already answered this in the comments, but just so this question has an answer, the problem was resolved through running:

sudo apt-get install python3-pymysql

Use:

import pymysql

Not:

import PyMySQL

That works for me.


After trying a few things, and coming across PyMySQL Github, this worked:

sudo pip install PyMySQL

And to import use:

import pymysql


If even sudo apt-get install python3-pymysql does not work for you try this:

  • Go to the PyMySQL page and download the zip file.
  • Then, via the terminal, cd to your Downloads folder and extract the folder
  • cd into the newly extracted folder
  • Install the setup.py file with: sudo python3 setup.py install