Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a discussion document about virtual environments #1344

Open
willingc opened this issue Nov 4, 2023 · 2 comments
Open

Create a discussion document about virtual environments #1344

willingc opened this issue Nov 4, 2023 · 2 comments

Comments

@willingc
Copy link
Contributor

willingc commented Nov 4, 2023

Before you can start installing or using packages in your virtual environment you’ll need to activate it.

While a virtual environment is activated, pip will install packages into that specific environment.

Activating a virtual environment will put the virtual environment-specific python and pip executables into your
shell's PATH.

Could these parts be updated as well? They are incorrect and actively misleading, leading to a lot of misunderstandings. A virtual environment can be used without activation. It depends on how / which pip is used. It would be fantastic if this guide could explain that in slightly more detail: Explicitly explain that activating is only (one way of) putting the the virtual environment-specific python and pip executables into the current shell's PATH. Specifying that path explicitly is also possible and often easier, preferred, clearer, more robust. The leaky abstraction "activation" and the lack of such an explanation is mystifying things unnecessarily, and leads to many problems and much confusion.

Originally posted by @petsuter in #1338 (comment)

@sinoroc
Copy link
Contributor

sinoroc commented Nov 4, 2023

We might need to consider that some things might rely on the presence of the VIRTUAL_ENV environment variable, which is set when activating a virtual environment.

@petsuter
Copy link

petsuter commented Nov 5, 2023

Apparently the Windows py launcher is aware of VIRTUAL_ENV (already since Python 3.5, (PEP 486 ). Nice. 👍

The The Python Launcher for Unix is also aware of VIRUAL_ENV https://python-launcher.app/#activated-virtual-environment
but also notes "In general, this feature is not needed. If you create a virtual environment in the current directory in a .venv directory, the Python Launcher will automatically use that. ... Otherwise it will search the parent directory, and so on, until it finds a .venv directory"

I think .venv directories are not automatically used by the Windows py launcher yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants