How do I install a Python package with a .whl file?
I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use
pip install some-package.whl
Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help:
How do I install pip on Windows?
Note: for clarification
If you copy the *.whl
file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --
pip install C:/some-dir/some-file.whl
Wheel file installation
You normally use a tool like pip
to install wheels. Leave it to the tool to discover and download the file if this is for a project hosted on PyPI.
For this to work, you do need to install the wheel
package:
pip install wheel
You can then tell pip
to install the project (and it'll download the wheel if available), or the wheel file directly:
pip install project_name # discover, download and install
pip install wheel_file.whl # directly install the wheel
The wheel
module, once installed, also is runnable from the command line, you can use this to install already-downloaded wheels:
python -m wheel install wheel_file.whl
Also see the wheel
project documentation.
How to install multiple .whl files in the right order
This directory full of wheel distribution files that you created is sometimes called a wheelhouse. They are often used to make repeatable and/or offline installations.
A common way to install from a wheelhouse is:
python -m pip install --no-index --no-deps path/to/wheelhouse/*.whl
If all the wheels for all dependencies and their dependencies are in the wheelhouse, then the installation order does not matter and there is no need to connect to any remote package index (for dependency resolution, etc.). That is why we can use the --no-deps
and --no-index
flags.
Reference:
- "Installation Bundles" section of pip's documentation
Aside:
Only now I fully appreciate the genius of pip and how it figures out the dependency tree on its own and manages to install every package in the right order.
pip's dependency resolver is resolvelib
. There is a simple example on its source code repository showing how to use it to solve for wheels on PyPI.
Pip Installing .whl files from requirements.txt Python
You can just refer to local file in requirement file this way:
./TA_Lib-0.4.24-cp37-cp37m-win_amd64.whl
Based on example
How to install python packages from whl files
I found the solution here. My pip
version was old. I upgraded it with:
python -m pip install --upgrade pip
Everything works fine now.
Related Topics
Loop "Forgets" to Remove Some Items
Flask View Return Error "View Function Did Not Return a Response"
Remove All the Elements That Occur in One List from Another
How to Convert All Strings in a List of Lists to Integers
String Comparison in Python: Is Vs. ==
Delete a Column from a Pandas Dataframe
Count the Frequency That a Value Occurs in a Dataframe Column
How to Convert an Rgb Image into Grayscale in Python
How to Create a List of Random Numbers Without Duplicates
Convert String to Variable Name in Python
Pygame Window Not Responding After a Few Seconds
Flask View Raises Typeerror: 'Bool' Object Is Not Callable
String Count With Overlapping Occurrences
How to Prettyprint a Json File
How to Count the Frequency of the Elements in an Unordered List