Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualenv creation is failing on Python embedded versions #1656

Closed
Pixel-Minions opened this issue Feb 18, 2024 · 13 comments · Fixed by #3161
Closed

Virtualenv creation is failing on Python embedded versions #1656

Pixel-Minions opened this issue Feb 18, 2024 · 13 comments · Fixed by #3161
Assignees
Labels
bug Something isn't working virtualenv Related to virtual environments windows Specific to the Windows platform

Comments

@Pixel-Minions
Copy link

Pixel-Minions commented Feb 18, 2024

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:

  1. Download an embedded version of Python.
  2. Unzip it on any folder.
  3. Append it to the PATH and make sure it is the Python version by default.
  4. run uv venv.
  5. Fails.

Best,

@Pixel-Minions
Copy link
Author

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.

@konstin
Copy link
Member

konstin commented Feb 26, 2024

What exactly do you mean by embedded version of python, could you link me to a download page?

@konstin konstin added the bug Something isn't working label Feb 26, 2024
@konstin
Copy link
Member

konstin commented Feb 27, 2024

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

@konstin konstin added the windows Specific to the Windows platform label Feb 27, 2024
@swz-git
Copy link

swz-git commented Mar 29, 2024

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)       

@Pixel-Minions
Copy link
Author

Yep, same error here. It seems uv is expecting specific files to be there. With virtualenv, there is no problem however.

@charliermarsh
Copy link
Member

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?

@konstin
Copy link
Member

konstin commented Apr 19, 2024

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.

@charliermarsh charliermarsh self-assigned this Apr 20, 2024
@charliermarsh
Copy link
Member

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: pypa/virtualenv#2368 (comment).

@charliermarsh
Copy link
Member

Can anyone just clarify for me what the motivating use-case is for using the embedded Pythons here?

@Pixel-Minions
Copy link
Author

Pixel-Minions commented Apr 20, 2024

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.

@charliermarsh
Copy link
Member

I added virtualenv-like support in #3161.

@joetristano
Copy link

Can uv install an embedded python version on windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working virtualenv Related to virtual environments windows Specific to the Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants