uv
uv copied to clipboard
Virtualenv creation is failing on Python embedded versions
Hi,
When I try to create a virtualenv from a Python Embedded version on Windows I get the following error:
Using Python 3.7.9 interpreter at C:\Users\alex\Documents\Python\python-3.7.9-embed-amd64\python.exe
Creating virtualenv at: .venv
uv::venv::creation
x Failed to create virtualenv
|-> failed to copy file from C:\Users\alex\Documents\Python\python-3.7.9-embed-amd64\Lib\venv\scripts\nt\python.exe
| to \\?\D:\testing\uv\.venv\Scripts\python.exe
`-> The system cannot find the path specified. (os error 3)
The path: C:\Users\alex\Documents\Python\python-3.7.9-embed-amd64\Lib\venv\scripts\nt\python.exe
doesn't exist.
The error is happening on Windows 10 and uv-0.1.4.
How to recreate the issue:
- Download an embedded version of Python.
- Unzip it on any folder.
- Append it to the PATH and make sure it is the Python version by default.
- run
uv venv
. - Fails.
Best,
Hey guys,
I wonder if there is any plans to support embedded version, I would really like to bring UV to the company and replace all the libraries we have with Poetry, but sadly, without being able to work with embedded versions, it seems like it won't work.
What exactly do you mean by embedded version of python, could you link me to a download page?
https://www.python.org/ftp/python/3.11.8/python-3.11.8-embed-amd64.zip
https://www.python.org/downloads/release/python-3118/
@konstin
Thanks!
I've checked with virtualenv
and apparently the strategy for supporting embeddable python version is to check for the shim and if it doesn't exist, copy all files: https://github.com/pypa/virtualenv/blob/cad550030ae77e181a1d7c328742a97f2880ef9b/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py#L58-L68
When running uv.exe venv testvenv --python .\python-3.11.8-embed-amd64\python.exe
, I get
Using Python 3.11.8 interpreter at: python-3.11.8-embed-amd64\python.exe
Creating virtualenv at: testvenv
uv::venv::creation
x Failed to create virtualenv
|-> failed to copy file from \\?\C:\Users\simlin1\Downloads\python-3.11.8-embed-amd64\venvwlauncher.exe to
| \\?\C:\Users\simlin1\Downloads\testvenv\Scripts\python.exe
`-> Det går inte att hitta filen. (os error 2)
Yep, same error here. It seems uv is expecting specific files to be there. With virtualenv, there is no problem however.
For starters can we get a minimal reproducible example for this? Like a Dockerfile that I can run to understand the current behavior and what the structure of these embedded Pythons looks like?
I can reproduce this when downloading the embedded python from (https://www.python.org/ftp/python/3.11.8/python-3.11.8-embed-amd64.zip) and using it for uv venv -p path\to\embedded\python
. The embedded python i looked at was a flat directory which we need to copy to support this.
I think I see what needs to be changed, and it looks relatively (?) straightforward. Though there are some comments from Paul Moore around this not being an intended use-case for the embedded distribution: https://github.com/pypa/virtualenv/issues/2368#issuecomment-1168574713.
Can anyone just clarify for me what the motivating use-case is for using the embedded Pythons here?
The comment you mentioned makes sense, there are ways around to create portable versions of python that might work with uv. I will try the nuget or winpython.
The reason for the embedded version is that, after some minor changes to the .pht file and using virtualenv, you can create portable virtual environment, it doesn't get linked to the interpreter source like if you would use a standard Python installation.
I added virtualenv-like support in https://github.com/astral-sh/uv/pull/3161.