How do I install Python libraries in wheel format?

127,496

Solution 1

You want to install a downloaded wheel (.whl) file on Python under Windows?

  1. Install pip on your Python(s) on Windows (on Python 3.4+ it is already included)
  2. Upgrade pip if necessary (on the command line)

    pip install -U pip
    
  3. Install a local wheel file using pip (on the command line)

    pip install --no-index --find-links=LocalPathToWheelFile PackageName
    

Option --no-index tells pip to not look on pypi.python.org (which would fail for many packages if you have no compiler installed), --find-links then tells pip where to look for instead. PackageName is the name of the package (numpy, scipy, .. first part or whole of wheel file name). For more informations see the install options of pip.

You can execute these commands in the command prompt when switching to your Scripts folder of your Python installation.

Example:

cd C:\Python27\Scripts
pip install -U pip
pip install --no-index --find-links=LocalPathToWheelFile PackageName

Note: It can still be that the package does not install on Windows because it may contain C/C++ source files which need to be compiled. You would need then to make sure a compiler is installed. Often searching for alternative pre-compiled distributions is the fastest way out.

For example numpy-1.9.2+mkl-cp27-none-win_amd64.whl has PackageName numpy.

Solution 2

If you want to be relax for installing libraries for python.

You should using pip, that is python installer package.

To install pip:

  1. Download ez_setup.py and then run:

    python ez_setup.py
    
  2. Then download get-pip.py and run:

    python get-pip.py
    
  3. upgrade installed setuptools by pip:

    pip install setuptools --upgrade
    

    If you got this error:

    Wheel installs require setuptools >= 0.8 for dist-info support.
    pip's wheel support requires setuptools >= 0.8 for dist-info support.
    

    Add --no-use-wheel to above cmd:

    pip install setuptools --no-use-wheel --upgrade
    

Now, you can install libraries for python, just by:

pip install library_name

For example:

pip install requests

Note that to install some library may they need to compile, so you need to have compiler.

On windows there is a site for Unofficial Windows Binaries for Python Extension Packages that have huge python packages and complied python packages for windows.

For example to install pip using this site, just download and install setuptools and pip installer from that.

Solution 3

To install wheel packages in python 2.7x:

  1. Install python 2.7x (i would recommend python 2.78) - download the appropriate python binary for your version of windows . You can download python 2.78 at this site https://www.python.org/download/releases/2.7.8/ -I would recommend installing the graphical Tk module, and including python 2.78 in the windows path (environment variables) during installation.

  2. Install get-pip.py and setuptools Download the installer at https://bootstrap.pypa.io/get-pip.py Double click the above file to run it. It will install pip and setuptools [or update them, if you have an earlier version of either]

-Double click the above file and wait - it will open a black window and print will scroll across the screen as it downloads and installs [or updates] pip and setuptools --->when it finishes the window will close.

  1. Open an elevated command prompt - click on windows start icon, enter cmd in the search field (but do not press enter), then press ctrl+shift+. Click 'yes' when the uac box appears.

A-type cd c:\python27\scripts [or cd \scripts ]

B-type pip install -u Eg to install pyside, type pip install -u pyside

Wait - it will state 'downloading PySide or -->it will download and install the appropriate version of the python package [the one that corresponds to your version of python and windows.]

Note - if you have downloaded the .whl file and saved it locally on your hard drive, type in
pip install --no-index --find-links=localpathtowheelfile packagename

**to install a previously downloaded wheel package you need to type in the following command pip install --no-index --find-links=localpathtowheelfile packagename

Solution 4

Have you checked this http://docs.python.org/2/install/ ?

  1. First you have to install the module

    $ pip install requests

  2. Then, before using it you must import it from your program.

    from requests import requests

    Note that your modules must be in the same directory.

  3. Then you can use it.

    For this part you have to check for the documentation.

Share:
127,496
user3212988
Author by

user3212988

Updated on December 18, 2020

Comments

  • user3212988
    user3212988 over 3 years

    I was looking for a tutorial on how to install Python libraries in the wheel format.

    It does not seem straightforward so I'd appreciate a simple step by step tutorial how to install the module named "requests" for CPython.

    I downloaded it from: https://pypi.python.org/pypi/requests and now I have a .whl file. I've got Python 2.7 and 3.3 on Windows, so how do I install it so all the other Python scripts I run can use it?

  • loopbackbee
    loopbackbee over 10 years
    It's worth mentioning that, using only these steps on a windows platform, many modules will simply fail to install if they need access to a compiler or specific library headers
  • Cu3PO42
    Cu3PO42 over 10 years
    In Windows pip doesn't even come with Python older than 3.4. You can install it from e.g. here.
  • mcarans
    mcarans over 9 years
    The Unofficial Windows Binaries for Python Extension Packages now contains only Python wheel files (.whl) installable using pip install library_name.
  • kuroi neko
    kuroi neko about 9 years
    Using Win7; after step 3 I'm stuck with get-pip.py telling me that pip is installed in whatever directory, but no pip executable to run. Any idea to relieve this definite pain I feel growing in my @ss?
  • Trilarion
    Trilarion about 9 years
    I wonder what you mean by "point it to the path of the .exe"?
  • Trilarion
    Trilarion about 9 years
    But what if the file from this location is not an installer but a .whl file?
  • Trilarion
    Trilarion about 9 years
    But what if you have a .whl file as the original asker said?
  • str8arrow
    str8arrow about 9 years
    NOTE I posted the above post earlier, mostly in uppercase, because I have an illness which makes it difficult to type. I just wanted to help, but was voted down for the uppercase.Formatting may be off for any number of reasons. Please consider those reasons..it may help someone else.
  • chip_wrangler
    chip_wrangler almost 9 years
    A so billed "Successfully installed pip-6.1.1" didn't work but "pip-Win" overcame that hurdle but could not install numpy (likley no compiler) which I needed. A "numpy superpack" overcame that hurdle. This summary makes it seem easy but it was far from a nice installation experience.
  • Trilarion
    Trilarion almost 9 years
    @chip_wrangler You're right. Package installations for Python under Windows can be pain in the ass (no compiler included in the OS by default). Often pre-compiled packages are the easiest way out. However I feel this is more the fault of Windows than of Python or any Python tool.
  • joaquin
    joaquin almost 9 years
    Unfortunately, not anymore. Everything is wheels now.