1

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?

ti7
  • 16,375
  • 6
  • 40
  • 68
Peter
  • 3,322
  • 3
  • 27
  • 41
  • What gives `no module named venv` error? – Code-Apprentice Nov 17 '21 at 16:24
  • 1
    This question is specific to *embeddable* python, which the video linked above does not mention. I updated the question to clarify that with *embeddable* python, running `python venv myenv` gives the `no module named venv` error. – Peter Nov 17 '21 at 16:27
  • `pip install venv` fails because `venv` is a built-in package, not a third party one hosted on pypi. I'm not sure why `python -m venv myenv` fails, though. Apparently it isn't included in the distribution. I assume because it isn't needed if you use the embeddable python as intended. – Code-Apprentice Nov 17 '21 at 16:31

1 Answers1

0

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.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • "though with some care it may be possible to include and use pip", and this works fine. This question is about how to do the same for venv. If you consider that redundant is irrelevant. – Peter Nov 17 '21 at 16:37
  • @Peter My point is that because using virtual environments with the embeddable distribution is redundant, trying to do so will be a path of much pain. I think it isn't possible to use `venv` in this way. since it is a built-in package for the typical python distribution, it isn't available through pypi. On the other hand, it appears that you found how to install `virtualenv`, so I suggest using that. They are identical (or at least nearly so). – Code-Apprentice Nov 17 '21 at 16:42
  • Installing `virtualenv` works, but using it doesn't as described in the original question. – Peter Nov 17 '21 at 16:43
  • @Peter I just saw that part and I'm not sure what is going on there. Is there more to the error message than what you pasted into your question? – Code-Apprentice Nov 17 '21 at 16:44
  • There's nothing more. But the message is accurate. There is no `DLLs` folder in embeddable python. So I guess virtualenv is confused and doesn't work correctly. The question is, can it be made to work anyway? – Peter Nov 17 '21 at 16:56
  • @Peter The link for embeddable python you gave states "The embedded distribution does not include the Microsoft C Runtime and it is the responsibility of the application installer to provide this." Since it is looking for a `DLLs` folder, this might be the issue. – Code-Apprentice Nov 17 '21 at 18:53