How do I install a Python package with a .whl file?

后端 未结 17 1970
刺人心
刺人心 2020-11-22 00:54

I\'m having trouble installing a Python package on my Windows machine, and would like to install it with Christoph Gohlke\'s Window binaries. (Which, to my experience, allev

相关标签:
17条回答
  • 2020-11-22 00:59

    I am in the same boat as the OP.

    Using a Windows command prompt, from directory:

    C:\Python34\Scripts>
    pip install wheel
    

    seemed to work.

    Changing directory to where the whl was located, it just tells me 'pip is not recognized'. Going back to C:\Python34\Scripts>, then using the full command above to provide the 'where/its/downloaded' location, it says Requirement 'scikit_image-...-win32.whl' looks like a filename, but the filename does not exist.

    So I dropped a copy of the .whl in Python34/Scripts, ran the exact same command over again (with the --find-links= still going to the other folder), and this time it worked.

    0 讨论(0)
  • 2020-11-22 01:02

    In-case if you unable to install specific package directly using PIP.

    You can download a specific .whl (wheel) package from - https://www.lfd.uci.edu/~gohlke/pythonlibs/

    CD (Change directory) to that downloaded package and install it manually by -
    pip install PACKAGENAME.whl
    ex:
    pip install ad3‑2.1‑cp27‑cp27m‑win32.whl

    0 讨论(0)
  • 2020-11-22 01:09

    You have to run pip.exe from the command prompt on my computer. I type C:/Python27/Scripts/pip2.exe install numpy

    0 讨论(0)
  • 2020-11-22 01:10

    There are several file versions on the great Christoph Gohlke's site.

    Something I have found important when installing wheels from this site is to first run this from the Python console:

    import pip
    print(pip.pep425tags.get_supported())
    

    so that you know which version you should install for your computer. Picking the wrong version may fail the installing of the package (especially if you don't use the right CPython tag, for example, cp27).

    0 讨论(0)
  • 2020-11-22 01:11

    New Python users on Windows often forget to add Python's \Scripts directory to the PATH variable during the installation. I recommend to use the Python launcher and execute pip as a script with the -m switch. Then you can install the wheels for a specific Python version (if more than one are installed) and the Scripts directory doesn't have to be in the PATH. So open the command line, navigate (with the cd command) to the folder where the .whl file is located and enter:

    py -3.6 -m pip install your_whl_file.whl
    

    Replace 3.6 by your Python version or just enter -3 if the desired Python version appears first in the PATH. And with an active virtual environment: py -m pip install your_whl_file.whl.

    Of course you can also install packages from PyPI in this way, e.g.

    py -3.6 -m pip install pygame
    
    0 讨论(0)
  • 2020-11-22 01:12

    First, make sure you have updated pip to enable wheel support:

    pip install --upgrade pip
    

    Then, to install from wheel, give it the directory where the wheel is downloaded. For example, to install package_name.whl:

    pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name
    
    0 讨论(0)
提交回复
热议问题