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

后端 未结 17 2268
刺人心
刺人心 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 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
    

提交回复
热议问题