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

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

    To be able to install wheel files with a simple doubleclick on them you can do one the following:

    1) Run two commands in command line under administrator privileges:

    assoc .whl=pythonwheel
    ftype pythonwheel=cmd /c pip.exe install "%1" ^& pause
    

    2) Alternatively, they can be copied into a wheel.bat file and executed with 'Run as administrator' checkbox in the properties.

    PS pip.exe is assumed to be in the PATH.

    Update:

    (1) Those can be combined in one line:

    assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%1" ^& pause
    

    (2) Syntax for .bat files is slightly different:

    assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause
    

    Also its output can be made more verbose:

    @assoc .whl=pythonwheel|| echo Run me with administrator rights! && pause && exit 1
    @ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause || echo Installation error && pause && exit 1
    @echo Installation successfull & pause
    

    see my blog post for details.

提交回复
热议问题