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

Pylint doesn't find the path set in .env and terminal.integrated.env.linux #433

Open
eromoe opened this issue Dec 18, 2019 · 8 comments
Open
Labels
bug Issue identified by VS Code Team member as probable bug needs PR

Comments

@eromoe
Copy link

eromoe commented Dec 18, 2019

Steps to cause the bug to occur

  1. Follow https://code.visualstudio.com/docs/python/environments#_use-of-the-pythonpath-variable
  2. add .env with some path like PYTHONPATH=/home/dc/sales_forecast/jobs/airflow:/home/dc/sales_forecast/sales_forecast
  3. add terminal.integrated.env.linux with {"PYTHONPATH": "/home/dc/sales_forecast/jobs/airflow:/home/dc/sales_forecast/sales_forecast"} to .vscode/settings.json
  4. run pylint

still show import error

PS: intelligence is working by set

"python.autoComplete.extraPaths": ["/home/dc/sales_forecast/jobs/airflow", "/home/dc/sales_forecast/sales_forecast"]

Your Jupyter and/or Python environment

Please provide as much info as you readily know

  • VS Code version: lastest
  • Setting python.jediEnabled: true | false
  • Python and/or Anaconda version: 3.7
  • OS: ubuntu 18.04
  • Virtual environment: conda
@eromoe eromoe added the bug Issue identified by VS Code Team member as probable bug label Dec 18, 2019
@karthiknadig karthiknadig self-assigned this Dec 18, 2019
@karthiknadig
Copy link
Member

@eromoe Did you run pylint in the terminal or did you set it up via extension settings?

@karthiknadig karthiknadig added the info-needed Issue requires more information from poster label Dec 19, 2019
@eromoe
Copy link
Author

eromoe commented Dec 19, 2019

I run pylint by ctrl + shift + p :
image

I found pylint become fine today , shouldn't PYTHONPATH take effect immediately ?

@brettcannon brettcannon removed the info-needed Issue requires more information from poster label Mar 24, 2020
@khs26
Copy link

khs26 commented Apr 2, 2020

Not sure whether it's a useful second reference, but this issue seems to be the same I raised in my
SO question

It appears that when using a virtual environment, pylint invocation looks like the following:

/path/to/venv/bin/python -m pylint --disable=all --enable=[...list of enabled warnings...] --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text /my/python/file.py

This doesn't apply any modifications to environment variables (including PYTHONPATH) specified in my python.envFile location.

@karthiknadig
Copy link
Member

We don't use the .env files when running linters. We don't run the linter is a specific terminal so, the settings there don't apply either. We have plans to move linting into language server process, this should allow for better handling of the environment variables.

@karthiknadig karthiknadig removed their assignment Oct 14, 2021
@pmuller
Copy link

pmuller commented Oct 1, 2022

Is there a workaround?

@karthiknadig
Copy link
Member

karthiknadig commented Oct 1, 2022

@pmuller You can set environment variables in a terminal outside of vscode from a terminal, then launch VS code from there using, code .

@tomaszstepinvest
Copy link

@karthiknadig It does not work for some reason at least not always.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Oct 31, 2023
@keenan-v1
Copy link

Hello from 2024! This is still an issue as far as I can tell, and the work-around is assuming all workflows are local, which is not ideal.

Please let me know if there's a work-around besides just not linting or disabling specific errors. It's frustrating that a Microsoft-endorsed extension wouldn't support .env given VSCode itself does.

I'll also start looking for alternatives :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug needs PR
Projects
None yet
Development

No branches or pull requests

8 participants