简体   繁体   中英

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.

use python -m pip install pymysql

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

sudo systemctl stop gunicorn

source env/bin/activate

python -m pip install pymysql

deactivate

sudo systemctl start gunicorn

works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM