Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

venv or virtualenv with embedded python

Python is available as an embeddable package (also known as the "embeddable zip file").

Tcl/tk (including all dependants, such as Idle), pip and the Python documentation are not included.

venv is not mentioned, but also seems to be missing:

C:\EmbeddablePython> python -m venv myenv
No module named venv

Is there a way to install it?

There is a way to install pip: pip with embedded python

But pip install venv fails:

ERROR: Could not find a version that satisfies the requirement venv (from versions: none)
ERROR: No matching distribution found for venv

pip install virtualenv works, but virtualenv myenv fails:

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\EmbeddablePython\\DLLs'

Is there a way to get venv or virtualenv working with the embeddable package of Python?

like image 411
Peter Avatar asked Aug 16 '26 01:08

Peter


1 Answers

virtualenv is a 3rd-party package, which is why you can install it with pip install virtualenv. On the other hand pip install venv will give an error, even with a conventional python installation, because venv is a built-in package that already exists in the standard python libraries. You should be able to do python -m venv <directory name>.

With that said, the documentation clearly states that pip is deliberately not included:

Third-party packages should be installed by the application installer alongside the embedded distribution. Using pip to manage dependencies as for a regular Python installation is not supported with this distribution, though with some care it may be possible to include and use pip for automatic updates.

This also indicates that the embeddable zip should be used as-is rather than creating virtual environments. The point of virtual environments is to isolate itself from other installations of python, especially any that may be used by the operating system. This allows you to install third-party dependencies with versions that may otherwise conflict with those installed by other python applications. By using the embeddable zip distribution, you already get this isolation, so using a virtual environment is redundant.

like image 112
Code-Apprentice Avatar answered Aug 17 '26 14:08

Code-Apprentice