Redstain
Redstain

Reputation: 187

No module named pymysql

Getting a 500 internal error when attempting to create an apache/django server that runs on digital ocean. After checking the log.error i can see the error below

import pymysql as db
ModuleNotFoundError: No module named pymysql

Within Terminal...

python --version
Python 3.8.5
sudo apt-get install python3-pymysql
python3-pymysql is already the newest version (0.9.3-2ubuntu3).
pip3 install PyMySQL
Requirement already satisfied: PyMySQL in /usr/lib/python3/dist-packages (0.9.3)

Within Python...

import pymysql as db

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

Any help would be appreciated.

Upvotes: 1

Views: 3237

Answers (2)

Rodrigo Neira
Rodrigo Neira

Reputation: 1

sudo systemctl stop gunicorn

source env/bin/activate

python -m pip install pymysql

deactivate

sudo systemctl start gunicorn

works for me.

Upvotes: 0

TheBigW
TheBigW

Reputation: 64

use python -m pip install pymysql

that used the pip for the Python interpreter you specified as python

Upvotes: 3

Related Questions