Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sabrasosimis opened this issue Oct 10, 2018 · 2 comments
Closed
Labels
area-editor-* User-facing catch-all area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@sabrasosimis
Copy link

sabrasosimis commented Oct 10, 2018

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.

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs PR labels Oct 10, 2018
@gramster gramster added the area-editor-* User-facing catch-all label Oct 10, 2019
@brettcannon
Copy link
Member

We are going through old issues and we noticed that no one had replied to this issue. I want to apologize for the oversight and to let you know that the issue was triaged (as shown by the labels applied to this issue).

@luabud
Copy link
Member

luabud commented Jul 20, 2021

We have released a new and more performant language server called Pylance which likely solves these issues you are reporting. You can download Pylance from the marketplace and install it alongside the core Python extension. Because our team's development efforts have shifted to support the new language server, we'd encourage you to try it out.

@luabud luabud closed this as completed Jul 20, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

5 participants