Skip to content

venv does not format PS1 correctly when activating on macOS #130952

@Calvin-coding

Description

@Calvin-coding

Bug report

Bug description:

When I create and activate a virtual environment using python -m venv myenv on macOS, the terminal prompt initially displays (myenv) correctly. However, after exiting VSCode and reopening it, the parentheses disappear, even though the virtual environment is still active. If activated again, an extra set of parentheses is added.

The default PS1 setting in activate: PS1="("myenv") ${PS1:-}"
should be corrected to: PS1="(myenv) ${PS1:-}"
as the extra quotes cause formatting issues.

Expected behavior:
The prompt should be (myenv) user@MacBook ~ %, but instead appears as myenvuser@MacBook ~ %.

Suggested fix:
Remove unnecessary quotes around "myenv" in the activate script.

Image Image

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-macstdlibStandard Library Python modules in the Lib/ directorytopic-venvRelated to the venv moduletype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions