Search code examples
pythonpip

How to pip install *.whl on Windows (using a wildcard)


For some reason, I cannot pip install %CD%\*.whl as I will then get:

Requirement 'C:\\Users\fredrik\\Downloads\\*.whl' looks like a filename, but the file does not exist
`*.whl is not a valid wheel filename.

On macOS (and I believe on Linux), I can do this without issues:

pip install *.whl
Processing ./certifi-2017.11.5-py2.py3-none-any.whl
Processing ./chardet-3.0.4-py2.py3-none-any.whl
Processing ./idna-2.6-py2.py3-none-any.whl
Processing ./requests-2.18.4-py2.py3-none-any.whl
Processing ./urllib3-1.22-py2.py3-none-any.whl
...

  1. Why is there a difference in this behavior between the platforms?
  2. Is there a preferred way to make this (pip install *.whl) work on Windows?

Solution

  • If you know the package name e.g. foo You can use this:

    python -m pip install --find-links=C:\Users\fredrik\Downloads foo
    

    this will find any foo package e.g. foo-X.Y.Z-cp37-cp37m-win_amd64.whl etc...

    If you don't know the package name then you can try to loop through all wheels:

    FOR %i in (C:\Users\fredrik\Downloads\*.whl) DO python -m pip install %i
    

    note: in a batch script you must use FOR %%i instead (and keep %i at the end).