Open eromoe opened 4 years ago
@eromoe Did you run pylint
in the terminal or did you set it up via extension settings?
I run pylint
by ctrl + shift + p
:
I found pylint become fine today , shouldn't PYTHONPATH
take effect immediately ?
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.
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.
Is there a workaround?
@pmuller You can set environment variables in a terminal outside of vscode from a terminal, then launch VS code from there using, code .
@karthiknadig It does not work for some reason at least not always.
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 :(
Steps to cause the bug to occur
.env
with some path likePYTHONPATH=/home/dc/sales_forecast/jobs/airflow:/home/dc/sales_forecast/sales_forecast
terminal.integrated.env.linux
with{"PYTHONPATH": "/home/dc/sales_forecast/jobs/airflow:/home/dc/sales_forecast/sales_forecast"}
to.vscode/settings.json
pylint
still show import error
PS: intelligence is working by set
Your Jupyter and/or Python environment
Please provide as much info as you readily know