Skip to content

.env support does not properly handle quoted values #17103

@marcogrcr

Description

@marcogrcr

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Steps to reproduce:

Create a .env file with the following content:

foo=bar
hello="world"

Create a .ipynb file with the following cell:

import os

print(f'foo == bar: {os.environ.get("foo") == "bar"}') # expected: True, actual: True
print(f'hello == world: {os.environ.get("hello") == "world"}') # expected True, actual: False
print(f'hello == "world": {os.environ.get("hello") == "\"world\""}') # expected False, actual: True

Expected:

os.environ.get('hello') returns 'world'

Actual:

os.environ.get('hello') returns '"world"'

The same problem occurs with single quotes. Note that python-dotenv properly handles quoted values.

VS Code Version

1.104.2

Jupyter Extension Version

v2025.8.0

Jupyter logs

Coding Language and Runtime Version

Python v3.12.3

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugfeature-requestRequest for new features or functionalitynotebook-executionKernels issues (start/restart/switch/execution, install ipykernel)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions