Denjack
Denjack

Reputation: 1

PYTHONPATH naming restrictions for vscode python linting

I am using vscode with python and other languages in a single project. The directory structure is like this:

- base
 - python
  - foo
    foo.py
  - bar
    bar.py
 - bin
 - etc

I am getting 'python(unresolved import)' warnings in vscode when importing modules such as 'foo'.

I used a solution provided by Tomasz C. here: Pylint "unresolved import" error in visual studio code

In my case I have a .env file with

PYTHONPATH=python/

This does not work!

I have renamed this portion of my directory structure to anything else (like PYTHONPATH=python2/) and it does work.

I have also tried multiple linters with no change.

I am not in control of the naming of these directories. Is there some way I can get linting with vscode to work with existing directory structure?

Upvotes: 0

Views: 92

Answers (1)

c0x6a
c0x6a

Reputation: 437

PYTHONPATH should point to a valid python executable instance, it should be the one being used by your environment, so you have to give it the full absolute path, not a relative one. example: /home/user/environment/bin/python, change it according to your setup.

Upvotes: 1

Related Questions