[DOCS] VS Code extension settings table missing usePythonEnvironment setting
Documentation Type
Missing documentation (feature not documented)
Documentation Location
https://code.claude.com/docs/en/vs-code
Section/Topic
"Extension settings" section under "Configure settings"
Current Documentation
The extension settings table lists these settings:
| Setting | Default | Description | | --- | --- | --- | |selectedModel|default| Model for new conversations. Change per-session with/model. | |useTerminal|false| Launch Claude in terminal mode instead of graphical panel | |initialPermissionMode|default| Controls approval prompts:default(ask each time),plan,acceptEdits, orbypassPermissions| |preferredLocation|panel| Where Claude opens:sidebar(right) orpanel(new tab) | |autosave|true| Auto-save files before Claude reads or writes them | |useCtrlEnterToSend|false| Use Ctrl/Cmd+Enter instead of Enter to send prompts | |enableNewConversationShortcut|true| Enable Cmd/Ctrl+N to start a new conversation | |hideOnboarding|false| Hide the onboarding checklist (graduation cap icon) | |respectGitIgnore|true| Exclude .gitignore patterns from file searches | |environmentVariables|[]| Set environment variables for the Claude process. Use Claude Code settings instead for shared config. | |disableLoginPrompt|false| Skip authentication prompts (for third-party provider setups) | |allowDangerouslySkipPermissions|false| Bypass all permission prompts. Use with extreme caution. | |claudeProcessWrapper| - | Executable path used to launch the Claude process |
What's Wrong or Missing?
The claudeCode.usePythonEnvironment setting is missing from the extension settings table.
This setting was added in version 2.1.21 (per the CHANGELOG.md) and enables automatic Python virtual environment activation, ensuring python and pip commands use the correct interpreter when working in Python projects.
Suggested Improvement
Add a new row to the extension settings table:
| Setting | Default | Description |
| --- | --- | --- |
| usePythonEnvironment | (unknown) | Automatically activate Python virtual environments, ensuring python and pip commands use the correct interpreter |
Impact
Medium - Makes feature difficult to understand
Additional Context
Affected Pages:
| Page | Section |
|------|---------|
| https://code.claude.com/docs/en/vs-code | Extension settings table |
Source: Claude Code v2.1.21 CHANGELOG.md states:
Python Virtual Environment (VSCode): Added automatic Python virtual environment activation, ensuringpythonandpipcommands use the correct interpreter (configurable viaclaudeCode.usePythonEnvironmentsetting)
22 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Can anyone tell me how to install pip and other python packages from within this claude container? It's pretty useless for me without any access to pip or python modules...
Hey @Tectract - good question! I think there might be some confusion about how Claude Code works.
Claude Code runs locally on your machine, not in a container. It has full access to your local Python installation, pip, and any packages you've installed. There's no sandboxed container limiting what you can do.
Quick Fix: Activate Your Virtual Environment First
Before launching Claude Code, activate your Python environment in the terminal:
Once activated, Claude can use
pythonandpipfrom that environment. For example, you can ask Claude to:pip install requeststo install packagesFor VS Code Users
The VS Code extension has a
claudeCode.usePythonEnvironmentsetting (added in v2.1.21) that automatically activates Python virtual environments. This is actually what the original issue is about - this setting isn't documented yet, but it exists!To enable it:
Cmd+,/Ctrl+,)Persistent Environment Setup
If you want your environment to persist across all Claude Code Bash commands, you can use the
CLAUDE_ENV_FILEapproach:Claude will source this file before each Bash command, keeping your environment active.
Note on "Claude Code on the Web"
If you're using Claude Code on the web (the browser version at claude.ai), that does run in an isolated VM. But the local CLI and VS Code extension run directly on your machine with full access to your development tools.
---
Let me know if you're still having trouble.
I'm running claude in a container using dev containers within VSCode. Isn't that what this repo is for?
I added the line
python3-pip \
in the dockerfile, under RUN apt-get, and now it SEES pip from the terminal, but I still can't install module yfinance.
pip3 install yfinance
error: externally-managed-environment
× This environment is externally managed
To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
Ah, Dev Containers! The "externally-managed-environment" error you're seeing is a Python/Debian thing (PEP 668), not specific to Claude Code. Modern Debian-based images block system-wide pip installs to prevent breaking the OS Python.
Quick Fix: Create a venv in your container
Add this to your Dockerfile:
Or if you want to do it interactively after the container starts:
Alternative: Use pipx for CLI tools
If you just need to run a Python package as a command-line tool:
Alternative: Override the restriction (not recommended)
You can force it with
--break-system-packages, but this can cause issues:For Claude Code specifically
Once you have a working Python environment in your container, Claude Code will use it. If you set up the venv in your Dockerfile, Claude will automatically have access to pip and your installed packages.
If you're launching Claude Code from a terminal where the venv is already activated, everything should just work. You can also use the
CLAUDE_ENV_FILEapproach I mentioned earlier to auto-activate the venv for each Bash command Claude runs.---
The Dev Containers setup is a good approach - just need to handle the venv inside the container. Let me know if you hit any other snags!
I added these lines belog the RUN apt-get section of the dockerfile
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
result: container failed to build:
Dockerfile-with-features:33
--------------------
31 | && apt-get clean && rm -rf /var/lib/apt/lists/*
32 |
33 | >>> RUN python3 -m venv /opt/venv
34 | ENV PATH="/opt/venv/bin:$PATH"
35 |
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c python3 -m venv /opt/venv" did not complete successfully: exit code: 1
tried to use the command:
python3 -m venv ~/.venv
in the container, after 'sudo apt-get install python3-venv' and rebuilding the container...
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.11-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: /home/node/.venv/bin/python3
pip3 install --break-system-packages yfinance
Usage:
pip3 install [options] <requirement specifier> [package-index-options] ...
pip3 install [options] -r <requirements file> [package-index-options] ...
pip3 install [options] [-e] <vcs project url> ...
pip3 install [options] [-e] <local project path> ...
pip3 install [options] <archive url/path> ...
no such option: --break-system-packages
sadly seems like I'm totally locked out of using pip here. Help? anyone?
The container is missing the venv packages. Here's a complete fix:
Complete Dockerfile Fix
Add these lines to your Dockerfile (before attempting to create the venv):
The key is installing
python3.11-venv(or whatever version matches your Python) - the genericpython3-venvpackage alone isn't enough on Debian/Ubuntu.If You Can't Modify the Dockerfile
Run these commands inside your container:
Alternative: Use uv (Recommended)
uv is a fast Python package manager that handles venvs automatically and doesn't hit PEP 668 issues:
This is actually what Anthropic recommends in their Agent SDK docs.
About the --break-system-packages flag
That flag was added in pip 23.0. Your container has an older pip. You could upgrade pip first, but honestly the venv approach is cleaner:
---
The root issue is that Dev Container base images often have minimal Python setups. Adding
python3.11-venvandpython3-fullto your Dockerfile should get you unstuck. Let me know if you hit anything else!(from within container)
sudo apt-get update
[sudo] password for node:
what is the password? I have no idea. Isn't the point of the container to prevent sudo commands that could alter the outside system?
sudo apt-get install python3-full:
E: Unable to locate package python3-full
sudo apt-get install python3.11-venv
E: Unable to locate package python3.11-venv
These appear to be non-existent packages in the default WSL ubuntu "focal" repos.
curl -LsSf https://astral.sh/uv/install.sh | sh
this worked and installed uv within my WSL command line...
however within the container:
zsh: command not found: uv
curl: (7) Failed to connect to astral.sh port 443 after 55 ms: Couldn't connect to server
So we are getting nowhere fast, here.
Can I add astral.sh to the allowed hosts file, maybe? and then it could get uv within the container? I'll try that, I guess...
Ah, Ubuntu Focal (20.04) - that explains a lot! The packages I mentioned are for newer Ubuntu versions. And the network restriction is blocking external downloads.
The fix has to happen in the Dockerfile (at build time), not inside the running container. Here's what should work:
For Ubuntu Focal (20.04)
Focal uses Python 3.8 by default, so use
python3.8-venv:Finding Your Dockerfile
Since you're using VS Code Dev Containers, look for one of these:
.devcontainer/Dockerfile.devcontainer/devcontainer.json(may reference a Dockerfile or use afeaturessection)If your
devcontainer.jsonuses a prebuilt image without a Dockerfile, you can add apostCreateCommand:But this still requires the venv packages to exist in the base image.
About the Network Issue
The container can't reach
astral.shbecause Dev Containers often restrict network access. If you need to allow specific hosts, check yourdevcontainer.jsonfor network settings, or ask your DevOps team about the network policy.About Sudo
The default password for the
nodeuser varies by base image. Common options:nodepasswordsudo -n apt-get update)But really, you shouldn't need sudo if the Dockerfile installs the packages at build time.
---
TL;DR: The packages need to be in the Dockerfile. For Focal, use
python3.8-venvinstead ofpython3.11-venv. Can you share what base image or devcontainer config you're using? That would help pinpoint the exact fix.Add this to your Dockerfile
RUN apt-get update && apt-get install -y \
python3-pip \
python3-venv \
python3.8-venv \
&& rm -rf /var/lib/apt/lists/*
on rebuild (is it using bookworm repos? I though WSL was using focal repos???)
=> ERROR [dev_container_auto_added_stage_label 3/12] RUN apt-get update && apt-get install -y python3-pip python3-venv python3.8-venv && rm -rf /var/lib/apt/lists/* 3.7s
------
When I do > sudo apt-get update under the WSL terminal this is what I see:
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
So I'm surprised it is trying to use bookworm repos within the container... Shouldn't those be the same?
when I type > less /etc/apt/sources.list.d/debian.sources (within the container terminal)
I see this:
Types: deb
# http://snapshot.debian.org/archive/debian/20260112T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
# http://snapshot.debian.org/archive/debian-security/20260112T000000Z
URIs: http://deb.debian.org/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
So now I'm super confused. Why is the container using different ubuntu repos than my WSL system???
passwords for > sudo apt-get update (within the container)
[sudo] password for node:
tried node, tried password, no dice. Are we just guessing here? Shouldn't that be part of the dockerfile settings or something? Shouldn't it properly NOT run sudo commands within the container? very confused. Feel like we are not making progress.
Using pip within a container seems impossible.
from the origina comment here:
What's Wrong or Missing?
The claudeCode.usePythonEnvironment setting is missing from the extension settings table.
This setting was added in version 2.1.21 (per the CHANGELOG.md) and enables automatic Python virtual environment activation, ensuring python and pip commands use the correct interpreter when working in Python projects.
Is this the core cause of the problem? Can I just update the "extension settings table" somehow to enable pip within the terminal again, somehow?
WSL vs Container - Two Different Systems
This is the source of confusion:
| System | OS | Where |
|--------|-----|-------|
| WSL | Ubuntu Focal (20.04) | Your Windows machine, outside the container |
| Dev Container | Debian Bookworm (12) | Inside Docker, isolated from WSL |
When you open the terminal in VS Code with a Dev Container, you're inside the container (Debian Bookworm), not in WSL. They're completely separate operating systems with different package repos.
So
python3.11-venvis the right package for your container (Bookworm has Python 3.11), but you can't install it because of the sudo password issue.About
usePythonEnvironmentUnfortunately, that setting won't help here. It auto-activates existing virtual environments - it doesn't create them or install packages. You still need a working Python/venv setup first.
The Real Fix: Modify the Dockerfile
The container's Python setup needs to happen at build time in the Dockerfile. You can't easily fix it from inside a running container without sudo access.
Quick question: What Dev Container are you using? Is it:
If you can share your
.devcontainer/devcontainer.json(and Dockerfile if there is one), I can show you exactly what lines to add.Workaround: Rebuild with Python Setup
If you have access to the devcontainer config, add this to your Dockerfile:
Or in
devcontainer.json, you can add a feature:This installs Python properly with venv support.
---
TL;DR: The
usePythonEnvironmentsetting is unrelated to your issue - it's about auto-activating existing venvs. Your container needs Python packages installed at build time. Share your devcontainer config and I can give you the exact fix!Found the issue! I looked at the official Claude Code dev container config.
The Problem
The official Claude Code dev container is Node.js focused - it doesn't include Python virtual environment support. Here's what's happening:
python3-venvinit-firewall.shscript restricts outbound connections to only:astral.shis NOT in the allowed list - that's whycurl -LsSf https://astral.sh/uv/install.shfailed with "Couldn't connect to server"/usr/local/bin/init-firewall.shhas NOPASSWD in sudoersThe Fix
You need to modify the Dockerfile to add Python support. Fork/copy the
.devcontainerfolder and add these lines:Alternative: Use a Dev Container Feature
In your
devcontainer.json, add the Python feature:This installs Python with pip and venv support without modifying the Dockerfile.
If You Need uv
Add
astral.shto the firewall allowed domains ininit-firewall.sh(line ~60):---
TL;DR: The official Claude Code container is designed for Node.js development, not Python. To use Python with pip, you need to either:
python3-venvto the Dockerfile, ordevcontainer.jsonThis might actually be worth a separate feature request - asking Anthropic to include Python support in the official dev container since Claude Code is commonly used for Python projects too.
In your devcontainer.json, add the Python feature:
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11",
"installTools": true
}
}
ok we are close here. pip is now available in the command line within the container.
yet still:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75da898997d0>: Failed to establish a new connection: [Errno 113] No route to host')': /simple/yfinance/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75da8989a6d0>: Failed to establish a new connection: [Errno 113] No route to host')': /simple/yfinance/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75da8989afd0>: Failed to establish a new connection: [Errno 113] No route to host')': /simple/yfinance/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75da8989bf50>: Failed to establish a new connection: [Errno 113] No route to host')': /simple/yfinance/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x75da8989cbd0>: Failed to establish a new connection: [Errno 113] No route to host')': /simple/yfinance/
ERROR: Could not find a version that satisfies the requirement yfinance (from versions: none)
ERROR: No matching distribution found for yfinance
Yes, finally, the solution here was to add teh python feature in the devcontainer, and then add these lines to the init-firewall.sh script ass allowed domains;
"pypi.python.org" \
"files.pythonhosted.org" \
finally, pip install yfinance is working without errors.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.