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

Add support for pip download command or fix "Failed to download distributions" error message in offline mode #2078

Closed
mborus opened this issue Feb 29, 2024 · 7 comments
Labels
compatibility Compatibility with a specification or another tool error messages Messaging when something goes wrong windows Specific to the Windows platform

Comments

@mborus
Copy link

mborus commented Feb 29, 2024

I've tried downloading and installing downloaded files with uv (0.1.12 (f68b2d1 2024-02-28)) and it seems
that pip's download functionality is not fully supported.

My use case: I need to install Python packages offline or with internet access filtered from a USB stick.

With pip I can issue this command

python -m pip download -r requirements.txt 

and it will download all required files into a folder

I can then copy this folder to a target machine with filtered (or no) internet and run

python -m pip install -r requirements.txt --no-index --find-links .

and install.

The download command is not supported by uv.
The offline install syntax seems to work (I used pip to download)
but throws an error "Failed to download distributions" (when it shouldn't attempt downloads)

(312_venv) C:\data\install\python312>python -m uv pip install -r requirements.txt --find-links . --no-index
Resolved 225 packages in 59.80s
error: Failed to download distributions
  Caused by: Failed to unzip wheel: pandas==2.2.1
  Caused by: failed to rename file from \\?\C:\Users\<removed>\AppData\Local\uv\cache\.tmpMqkbVd to \\?\C:\Users\<removed>\AppData\Local\uv\cache\archive-v0\gG2ZOtGzn-FK9d-qIxqXW
  Caused by: Zugriff verweigert (os error 5)

After installing with pip, the next run of uv works fine and reports

 Audited 49 packages in 199ms

Testcase for Windows 10 to reproduce problem

On internet connected PC

On offline PC

  • Connect USB stick
  • Install Python 3.12.2 for all Users
  • Use CMD.EXE to move inside the folder
  • create a venv and activate it
  • run "python -m pip install uv pip --no-index --find-links ."
  • run "python -m uv pip install -r requirements.txt --no-index --find-links ."
@konstin konstin added the compatibility Compatibility with a specification or another tool label Feb 29, 2024
@konstin
Copy link
Member

konstin commented Feb 29, 2024

The failed to download error is misleading, the error that renaming the file failed. Could you have the same problem about some corporate security software as in #1491 ?

@mborus
Copy link
Author

mborus commented Feb 29, 2024

The failed to download error is misleading, the error that renaming the file failed. Could you have the same problem about some corporate security software as in #1491 ?

Thanks, yes that's a good guess, because the reason why I install from downloads is to get around our firewall.
And there's strange virus scanning going on. I never had problems like this with pip in years...

To check I ran the whole testcase fresh and it finished without an error. So uv can install from a folder.

It would be nice to change the confusing error message (and to include pip's download flag) and maybe some needed retry logic.

@konstin konstin added error messages Messaging when something goes wrong compatibility Compatibility with a specification or another tool and removed compatibility Compatibility with a specification or another tool labels Feb 29, 2024
@omdaniel
Copy link

omdaniel commented Feb 29, 2024

I am not sure the pip has the same mechanism of unziping a package and then nearly instantaneously trying to access the contents, perhaps this is a side effect of the speed of execution. My hunch is that simply retrying several times after the os send a read access error would resolve this particular issue at the expense of adding some complexity to the code for an issue that probably only effects an exceedingly small fraction of users

@konstin
Copy link
Member

konstin commented Mar 1, 2024

I'd be fine with adding retry workarounds, but i'd need an environment to reproduce and test the fix.

@mborus
Copy link
Author

mborus commented Mar 1, 2024

I'd be fine with adding retry workarounds, but i'd need an environment to reproduce and test the fix.

One work around that could help terminal users is an optional parameter that asks the user to confirm retries if uv decides that it has a file access error. I could test a fix attempt mid next week when I come in for an office workday.

@johannesloibl
Copy link

We have the same problem frequently on our Windows-based Gitlab runners.
Usually re-running solves the issue most of the times, but it's pretty annoying.

error: Failed to download and build `fire==0.6.0`
  Caused by: Failed to write to the distribution cache
  Caused by: failed to rename file from \\?\D:\glb\r8ALcmRh\0\global_projects\.....\.cache\uv\built-wheels-v3\.tmpVhMjHj\fire-0.6.0 to \\?\D:\glb\r8ALcmRh\0\global_projects\.....\.cache\uv\built-wheels-v3\index\70e6dbc41e17fe7c\fire\0.6.0\-zjUg4RGmAQ8yytArRU5B\fire-0.6.0.tar.gz
  Caused by: Access is denied. (os error 5)

@konstin konstin added the windows Specific to the Windows platform label Jul 2, 2024
@zanieb
Copy link
Member

zanieb commented Jul 4, 2024

I think regarding the Windows problem we have #4605 / #1491 and for pip download we have #3163 to track these things.

@zanieb zanieb closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with a specification or another tool error messages Messaging when something goes wrong windows Specific to the Windows platform
Projects
None yet
Development

No branches or pull requests

5 participants