Open In App

How to Install a Python Package with a .whl File?

Last Updated : 21 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how we can install a Python Package with a .whl file. 

Users must have Python 3.x (any version like 3.9,3.10 etc) installed on their device and may download any .whl file of their choice prior to following this article. The user should also need to verify that pip is already installed too.

What is a wheel file?

It is a built-package format for Python. A wheel could be a ZIP-format archive with a specially formatted name and therefore the .whl extension. it’s designed to contain all the files for a PEP 376 compatible, install in such a way that is very close to the on-disk format. several packages are properly put in with solely the “Unpack” step (simply extracting the file onto sys.path), and therefore the unpacked archive preserves enough info to “Spread” (copy information and scripts to their final locations) at any later time.

Method 1: Using Powershell + pip + cd (change directory command).

Step 1: First, we need to download our desired .whl file from the official PyPi website (pypi.org), open the website and click on browse projects.

 

Step 2: After clicking browse projects click on the Python 3 compatible projects

 

Step 3: After clicking Python 3 compatible projects, search for the desired package of user’s choice. In this tutorial I will be downloading and installing the PyAudio package so I will download that (user might download any other package, the process of installation is same).

 

Step 4: After searching and finding the package user wants, the user needs to click on that package, and on the left there would be a section called Download files (under Navigation), click on that and the user will see .whl file of different versions of the package. Here the user needs to be very careful about the Python version they have installed on their device and the type of OS is installed in their machine (32 or 64-bit). For Windows and AMD 64-bit, the same file will work on both, if the user has 32-bit installed then download the file which has win32 in its name.

Just click on the specific package and it will be downloaded.

 

The first version is the latest one which supports Python 3.11 and will run on Windows and AMD 64-bit machines, the second one also supports Python 3.11 but will work on Windows 32-bit machines. Then the third and the fourth support Python 3.10 64bit and 32bit machines etc.

Step 5: Now open Windows Powershell in Administrator mode, then change the directory using the cd command to where the downloaded file is located.

cd <Entire_Path_of_the_folder_in_which_it_is_downloaded>

 

Step 6: Now as we are now in the folder where it has been downloaded, run the following command in Powershell.

pip install <downloaded_wheel_filename_with_extension>

 

Method 2: Using Powershell + pip.

Step 1: Open Windows Powershell in Administrator mode.

Step 2: Just run the below command

pip install <Location_of_the_downloaded_file\entire_filename_with_extension>

 

Solutions of some problems user might face while installing –

  • If users face any problem running the command in PowerShell regarding any ‘Permission’, then they should close and reopen the Powershell As Administrator.
  • Sometimes in the case of Python 3.x user needs to use pip3 instead of pip, so if the user gets any error regarding the pip (except: ‘Pip’ is not recognized as an external or internal command, for this purpose user needs the to add the location of pip in the path inside system variable, or simply reinstall Python or Modify it and while doing so check the option ADD to Path.

 

 

  • The user using an old version of pip, upgrades it by running the below command.
pip install --upgrade pip

or

python -m pip install --upgrade pip
  • If the pip or pip3 command still gives an error then the user should use the following command.
python -m pip install <package_name.whl>

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads