2

In order to have code-completion and functioning linting, I'd like VSCode to include a specific path.

https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file

I created a test environment

$ pwd
==> /Users/stephan/saitc/test_ws

$ ls -a
==> .           .env            tst_pckg
==> ..          __init__.py
==> .DS_Store   testing.code-workspace

$ cat .env
==> PYTHONPATH="/Users/stephan/saitc"

$ ls tst_pckg/
==> CONST.py        __init__.py     testing.py

$ cat tst_pckg/CONST.py
==> # -*- coding: utf-8 -*-
==> 
==> TEST_CONSTANT = "Test constant's value"

$ cat tst_pckg/testing.py
==> # -*- coding: utf-8 -*-
==> 
==> from test_ws.tst_pckg.CONST import TEST_CONSTANT

The setting "python.envFile" is set to "${workspaceFolder}/.env"

With this setup I would expect that VSCode is aware of the package "test_ws" but typing the line:

from test_ws.tst_pckg.CONST import TEST_CONSTANT

in the file "testing.py" gives my no reasonable code completion and "test_ws.tst_pckg.CONST" can not be resolved ("unresolved import"-error in the VSCode ui).

I'm using Anaconda on macos and the Visual Studio Code 1.30.1 which comes with it. Can it be that I have to start visual studio code from the directory "/Users/stephan/saitc/test_ws"? (if so how?)

With every start of Visual Studio Code I'm asked if I want to start the pylint extension. How can I turn this on permanently? (Python›Linting: Pylint Enabled, Python›Linting: Enabled)

Thank you,

Stephan

Stephan Lukits
  • 306
  • 2
  • 8
  • I think this question is a duplicate of https://stackoverflow.com/questions/53939751/pylint-unresolved-import-error-in-visual-studio-code – Elias May 13 '20 at 06:23

1 Answers1

0

You can use the configuration "python.autoComplete.extraPaths": ["./your-source/folder"].

As far as I understand is the env file only used when you start a terminal and so on but not for the extensions.

Elias
  • 515
  • 5
  • 10