Skip to content

cannot go to definition when using relative path for PYTHONPATH in .env #2841

@sabrasosimis

Description

@sabrasosimis

Environment data

  • VS Code version: 1.28
  • Extension version (available under the Extensions sidebar): 2018.9.0
  • OS and version: ubuntu 18.04
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6.6

Description of the issue

I work on a project were a python project is located on a subfolder of the root project, eg :
/my-project/docs
/my-project/docker
/my-project/app/src <---- the root of the python project

Following advices found here and there, I set a .env file in the root path (/my-project/.env) and set the PYTHONPATH using relative path PYTHONPATH=./app/src as advised in #955

Most of the features seem to work ok (autocompletion, linting,...) however :

  • if I try to 'go to definition' in the code, it just says No definition found for xxxxx
  • if I try to 'go to definition' on the import itself, it sometimes says Unable to open '__init__.py': File not found (file:///LOCAL-PATH/app/src/__init__.py). (depending on the project. some just says No definition found for xxxxx). The projects have the init.py file well located.

So to have a workable environment, I have to set an absolute path in the .env file, which makes it non sharable / portable, which is not wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-editor-*User-facing catch-allarea-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions