skip to Main Content

My VSCode doesn’t recognize modules and libraries imported in Python scripts, and shouts Unable to import ### PylintE0401:import-error at every single module import statement.

enter image description here

The Python scripts run without any issues. I’m always initializing poetry shell by running poetry shell and it’s always activated. So I’m sure PyLint is pointing to a wrong interpreter, but I don’t know what I should put in what settings.

Here are some of the command outputs.

poetry env list 
.venv (Activated). -> I'm choosing this environment in settings (Python: Select Interpreter)

poetry env info --path
/Users/makotomiyazaki/repos/Sakana/writing-assistant/.venv

poetry config virtualenvs.path
/Users/makotomiyazaki/Library/Caches/pypoetry/virtualenvs

2

Answers


  1. I had a similar issue, but after I had closed vscode and restarted it the pylint message had resolved itself.

    Login or Signup to reply.
  2. First, make sure that you have selected the correct Python interpreter for your project, e.g. by using the Python: Select Interpreter command.

    Next, open your settings and search for Pylint. Locate the Pylint: Import Strategy option, and choose fromEnvironment.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search