question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use intellisense and code navigation

See original GitHub issue

Hi I am working on the project which has a huge code base involving many many python source code files. I am using python extension and vscode for the first time and I am running into the following issue.

I have a python file located in path : a/b/c/d/e/legacy/file_reader.py This is imported in the second python file using the following method :

import os import sys sys.path.append(“a/b/c/d/e/legacy”) import file_reader_legacy

In this usage, I observe that the IntelliSense and code navigation work normally However, in our project we define many environment variables which point to paths that can be used in python to import. For example :

import os import sys sys.path.append(os.environ[‘PATH_TO_FILE_READER’] + “/legacy”) ==> PATH_TO_FILE_READER is an environment variable which points to a/b/c/d/e/ import file_reader_legacy

In this usage, I observe that the IntelliSense and code navigation don’t work at all. That is when I select Go to definition option, the extension is not able to navigate to the definition of the method Using absolute paths in our project is not suitable since our codebase has to support many variations and hence we try our best to abstract this as much as possible.

Please note I have created a file called: python_env.env in my ./vscode directory. This file has the definition of environment variables inside it. for example, .vscode/python_env.env PATH_TO_FILE_READER=${PATH_TO_FILE_READER}

I have also defined the following in .vscode/settings.json and .vscode/vscode_workspace.code_workspace files “python.envFile”: “${workspaceFolder}/python_env.env”

Can I kindly get some help in this matter?

Environment data

  • VS Code version: 1.45.1
  • Extension version (available under the Extensions sidebar): 2020.5.80290
  • OS and version: Linux 3.0.101-108.108-default
  • Python version (& distribution if applicable, e.g. Anaconda): 3.5.4 64 bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): set to default setting
  • Value of the python.languageServer setting: set to the default setting

Expected behaviour

Please see the description above

Actual behaviour

Please see the description above

Steps to reproduce:

Please see the description above

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
sourabh2902commented, Jun 23, 2020

thanks for the help ! now it is working

0reactions
karrtikrcommented, Jun 22, 2020

@sourabh2902 Note Jedi doesn’t pick changes from sys.path. You’ll have to set PYTHONPATH environment variable to the relative path of the directory (to workspace) where modules are imported from. See this for more details.

If it still doesn’t work our for you, please give me small reproducible example with file directory structure, file contents, .env file. My understanding of the problem is this,

  • If you don’t use the environment variable, things work fine for you.
  • If you use the environment variable, and set it correctly (you checked by printing the values of variable), things still do not work for you.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellisense not working, cannot navigate to the symbol under ...
Hi, I upgraded my projects from Visual Studio 2017 to Visual Studio 2019 last week, and I haven't been able to use VS2019...
Read more >
IntelliSense not working in VS Code - The Windows Club
Open up VS Code. Go to Extensions Panel (Ctrl+Shift+X). Search for 'Intellisense + [Name of language]'. For example, 'Intellisense Python'.
Read more >
Intellisense not automatically working VSCode - Stack Overflow
This usually happens after I have a file open that needs to use type information from another file I just created.
Read more >
Intellisense not working for Visual Studio Code - Unity Forum
Problem: 1. Intellisense and Autocomplete not working for VScode. 2. Opening c# script within the editor opens VSCode. However, VScode Doesn't ...
Read more >
IntelliSense in Visual Studio - Microsoft Learn
The cursor is below a code error. You might not be able to use IntelliSense if an incomplete function or other error exists...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found