Skip to content

.env file not working #9358

Description

@timkgh

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2019.11.50794
  • OS and version: macOS 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions:
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): Language Server ("python.jediEnabled": false)

Expected behaviour

Env vars set in .env file should be present in python and in terminal.

Actual behaviour

Env vars missing.

Steps to reproduce:

  1. Create an empty folder, brand new simple workspace
  2. Create a .env file in the workspace folder
  3. Set a variable FOO=bar in the .env file
  4. Run a simple envtest.py python file via Cmd+Shift+P: "Run python file in terminal"
import os
print(os.environ.get('FOO'))
  1. The printed value is None, the env var is not set
  2. The env var is also not present in the integrated VSCode terminal echo $FOO

FWIW, I also tried setting python.envFile in .vscode/settings.json to the absolute path of the .env file and it still does not work.

Metadata

Metadata

Labels

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