1

Today, I have updated a code repository and moved around some code/directories. In Pycharm I have debugged it and it's running with no errors (and all imports working). When I open the same project directory in VSCODE it gives me import-errors saying it is unable to import my modules, however it can import the packages. If I retype the exact same import statement in VSCODE, it now works (see image, for reference I have checked with only one statement and it still works). Why does it do this?

Import statement example screenshot

I have tried clearing the caches (using "Clear Editor History" in command palette). As well as putting

"env": {"PYTHONPATH": "${workspaceRoot}"}

in my launch.json

VSCODE: 1.39.2 with Docker, Importmagic and Python extensions. Ubuntu 18.04 LTS Python 3.7.5 in a venv

Can someone suggest how I go about resolving this without having to retype all my import statements. I know it'll be something simple but after a quick search I can't seem to resolve it.

Thanks!

jmar
  • 11
  • 3

1 Answers1

0

It was naivety on my part, moving between PyCharm and VSCODE changed my working directory level. And therefore changing the import path to suit fixed it.

And following this answer:

PyLint "Unable to import" error - how to set PYTHONPATH?

jmar
  • 11
  • 3