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

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

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

    I would be suggesting you the exact way how to install .whl file. Initially I faced many issues but then I solved it, Here is my trick to install .whl files.

    Follow The Steps properly in order to get a module imported

    1. Make sure your .whl file is kept in the python 2.7/3.6/3.7/.. folder. Initially when you download the .whl file the file is kept in downloaded folder, my suggestion is to change the folder. It makes it easier to install the file.
    2. Open command prompt and open the folder where you have kept the file by entering

    cd c:\python 3.7

    3.Now, enter the command written below

    >py -3.7(version name) -m pip install (file name).whl
    
    1. Click enter and make sure you enter the version you are currently using with correct file name.

    2. Once you press enter, wait for few minutes and the file will be installed and you will be able to import the particular module.

    3. In order to check if the module is installed successfully, import the module in idle and check it.

    Thank you:)

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

    There's a slight difference between accessing the .whl file in python2 and python3.In python3 you need to install wheel first and then you can access .whl files.

    Python3

    pip install wheel
    

    And then by using wheel

    wheel unpack some-package.whl
    

    Python2

    pip install some-package.whl
    
    0 讨论(0)
  • 2020-11-22 01:26

    On Windows you can't just upgrade using pip install --upgrade pip, because the pip.exe is in use and there would be an error replacing it. Instead, you should upgrade pip like this:

    easy_install --upgrade pip
    

    Then check the pip version:

    pip --version
    

    If it shows 6.x series, there is wheel support.

    Only then, you can install a wheel package like this:

    pip install your-package.whl
    
    0 讨论(0)
  • 2020-11-22 01:26

    Download the package (.whl).

    Put the file inside the script folder of python directory

    C:\Python36\Scripts
    

    Use the command prompt to install the package.

    C:\Python36\Scripts>pip install package_name.whl
    
    0 讨论(0)
提交回复
热议问题