7

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?

4
  • What gives no module named venv error? Commented Nov 17, 2021 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. Commented Nov 17, 2021 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. Commented Nov 17, 2021 at 16:31
  • python-3.12.1-embed-amd64.zip has no venv module, no idea why... :( Commented Jan 26, 2024 at 9:24

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

"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 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).
Installing virtualenv works, but using it doesn't as described in the original question.
@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?
@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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.