0

I created a virtual environment using python3.9 -m venv myenv Now I activate it using source myvenv/bin/activate.

I suppose from this virtual enviroment is some dependency or link created to the installed Python version.

When I uninstall python3.9 can I still launch my python script with this activated virtual enviroment?

hc_dev
  • 8,389
  • 1
  • 26
  • 38
sleli
  • 7
  • 1
  • Does this answer your question? [Consequences for virtual env when system's Python is removed and/or updated](https://stackoverflow.com/questions/55025873/consequences-for-virtual-env-when-systems-python-is-removed-and-or-updated) – hc_dev Dec 19 '22 at 17:59

2 Answers2

1

no you wont be able to run python applications anymore.

refer https://docs.python.org/3/library/venv.html venv — Creation of virtual environments¶ New in version 3.3.

Source code: Lib/venv/

The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

See PEP 405 for more information about Python virtual environments.

jawath
  • 439
  • 7
  • 22
0

If deleting the installed Python version affects the further use of any virtual environment depends wether option symlinks or copies was used when the virtual environment was created.

From Python docs for module venv, Creating virtual environments:

It also creates a bin (or Scripts on Windows) subdirectory containing a copy/symlink of the Python binary/binaries (as appropriate for the platform or arguments used at environment creation time).

Emphasis mine, to note that the role of the installed Python version depends on options.

The installed Python version is still a dependency, when at the time of creation symlinks have been used. If copies have been used, then the virtual environment is independent of the Python installed version and it can be removed.

See the options:

--symlinks Try to use symlinks rather than copies, when symlinks are not the default for the platform.

--copies Try to use copies rather than symlinks, even when symlinks are the default for the platform.

See also: PEP 405: Copies versus symlinks

hc_dev
  • 8,389
  • 1
  • 26
  • 38
  • You may get a copy of the *binary*, but it might still be hard-coded to use a standard library that was also removed. – chepner Dec 19 '22 at 18:34