0

I'm trying to import pymysql to my python script in VSCode but am getting the following error

Import "pymysql" could not be resolved from sourcePylancereportMissingModuleSource

I installed the module with pip the same way I have with all other modules such as Pandas, which works fine

Here's the import line for reference

import pymysql

Any quick fixes or explanations of what is going on would be appreciated, thanks

1
  • Has your question been resolved? Commented Aug 10, 2021 at 6:46

6 Answers 6

3
  1. Check for the current Python Interpreter VSCode is using Ctrl+P.

  2. Add your virtual environment PATH where your module is installed in 'C:\Users\<username>\.virtualenvs\<virtualenvname>\Scripts\python'.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to add your current working directory to the Python search path. This can be done with an environment variable:

export PYTHONPATH=.

There is a similar question here: Import "flask" could not be resolved from sourcePylancereportMissingModuleSource

Comments

1

run python3 -m pip install pymysql if you continue experiening the same proplem, please change your python interpreter from global to windows store from the interpreter section

Comments

0

Run pip show pymysql to check if module is installed in \current selected interpreter\lib\site-packages:

enter image description here

If not, please reinstall it to current used environment. If it is, open Command Palette(Ctrl+Shift+P) and choose Reload Window, the warning should go away.

Comments

0

Maybe it's late, but in my case issue was solved by redoing virtual environment in my project with flask and pymysql. My .env was previously created working with flask.

In VS: View -> Command Palette -> Python environment -> .venv -> Delete and Recreate

After recreate:

python -m pip install flask
python -m pip install pymysql

In case this could help somebody.

Comments

-1

It's pretty simple:

To solve the error, install the module by running the pip install pymysql command.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.