如何安装带有.whl文件的Python包?

时间:2023-01-12 19:57:13

I'm having trouble installing a Python package (specifically, JPype1 0.5.7) on my Windows machine, and would like to install it with Christoph Gohlke's Window binaries. (Which, to my experience, alleviated much of the fuss for many other package installations.)

我在Windows机器上安装Python包(具体地说,是JPype1 0.5.7)有困难,我想用Christoph Gohlke的窗口二进制文件来安装它。(根据我的经验,这大大缓解了许多其他软件包安装的麻烦。)

However, while Christoph used to provide .exe files in the past, recently it seems he's uploading .whl files instead.

然而,虽然Christoph过去曾提供.exe文件,但最近他似乎上传了.whl文件。

http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

http://www.lfd.uci.edu/ gohlke pythonlibs / # jpype

But how do I install .whl files?

但是如何安装。whl文件呢?

Notes:

注:

  • I've found documents on wheel, but they don't seem so staightforward in explaining how to install .whl files.
  • 我在wheel中找到了文档,但是在解释如何安装.whl文件时,它们似乎不太可靠。
  • This question is a duplicate with this question, which wasn't directly answered.
  • 这个问题和这个问题是重复的,没有直接回答。

14 个解决方案

#1


702  

I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use

我只是用了下面这个很简单的方法。首先打开一个控制台,然后cd到你下载文件的地方,比如某个包。whl和使用

pip install some-package.whl

Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help: How do I install pip on Windows?

注意:如果皮普。exe无法识别,您可以在python安装的“Scripts”目录中找到它。如果pip没有安装,这个页面可以提供帮助:如何在Windows上安装pip ?

Note: for clarification
If you copy the *.whl file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --

注:如需澄清,请将*复制。whl文件到您的本地驱动器(例如C:\some-dir\some-file.whl)使用以下命令行参数——

pip install C:/some-dir/some-file.whl

#2


47  

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

要从轮上安装,请给它一个下载轮的目录。例如,要安装package_name.whl:

pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name

Make sure you have updated pip first to enable wheel support:

确保您已经更新了pip,以支持轮支持:

pip install --upgrade pip

#3


18  

I am in the same boat as the OP.

我和OP在同一条船上。

Using a Windows command prompt, from directory:

使用Windows命令提示符,从目录:

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.

将目录更改为whl所在的位置,它只告诉我“pip不被识别”。回到C:\Python34\Scripts>,然后使用上面的完整命令来提供“where/its/download”位置,它说需求“scikit_image-…-win32”。whl'看起来像文件名,但文件名不存在。

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.

因此,我在Python34/Scripts中删除了.whl的一个拷贝,再次运行相同的命令(使用—find-links=仍然转到另一个文件夹),这次它成功了。

#4


12  

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

你必须运行pip。从我的计算机上的命令提示符。我输入C:/ / pip2 Python27 /脚本。exe安装numpy

#5


9  

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

在伟大的Christoph Gohlke的网站上有几个文件版本。

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

当我从这个站点安装*时,我发现重要的一点是首先从Python控制台运行这个:

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).

这样你就知道应该为你的电脑安装哪个版本。选择错误的版本可能会导致软件包的安装失败(特别是如果您不使用正确的CPython标记,例如cp27)。

#6


7  

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:

在Windows上,您不能仅仅通过pip安装升级——升级pip,因为pip。exe正在使用中,将会有一个错误替换它。相反,您应该这样升级pip:

easy_install --upgrade pip

Then check the pip version:

然后检查pip版本:

pip --version

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

如果它显示6。x系列,有滚轮支撑。

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

只有这样,你才能安装这样的轮包:

pip install your-package.whl

#7


4  

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

要安装带有简单doubleclick文件的轮文件,您可以执行以下操作:

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

1)在管理员权限下运行命令行中的两个命令:

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.

或者,它们可以被复制到一个*中。bat文件并在属性中使用“作为管理员运行”复选框执行。

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

PS皮普。假设exe在路径中。

Update:

更新:

(1) Those can be combined in one line:

(1)可合并为一行:

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

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

(2) .bat文件的语法略有不同:

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.

详情请参阅我的博客文章。

#8


2  

To avoid having to download such files, you can try:

为了避免下载这些档案,你可以尝试:

pip install --use-wheel pillow

For more information, see this.

有关更多信息,请参见本文。

#9


1  

The only way I managed to install NumPy was as follows:

I downloaded NumPy from here https://pypi.python.org/pypi/numpy

我从这里下载了NumPy https://pypi.python.org/pypi/numpy

This Module

https://pypi.python.org/packages/d7/3c/d8b473b517062cc700575889d79e7444c9b54c6072a22189d1831d2fbbce/numpy-1.11.2-cp35-none-win32.whl#md5=e485e06907826af5e1fc88608d0629a2

Command execution from Python's installation path in PowerShell

PS C:\Program Files (x86)\Python35-32> .\python -m pip install C:/Users/MyUsername/Documents/Programs/Python/numpy-1.11.2-cp35-none-win32.whl
Processing c:\users\MyUsername\documents\programs\numpy-1.11.2-cp35-none-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.2
PS C:\Program Files (x86)\Python35-32>

PS.: I installed it on Windows 10.

我把它安装在Windows 10上了。

#10


1  

What I did was first updating the pip by using the command: pip install --upgrade pip and then I also installed wheel by using command: pip install wheel and then it worked perfectly Fine. Hope it works for you I guess.

我所做的是首先使用命令来更新pip: pip安装——升级pip,然后我还使用命令安装了*:pip安装轮,然后它运行得非常好。希望对你有用。

#11


0  

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:

Windows上的新Python用户在安装过程中经常忘记将Python的\脚本目录添加到PATH变量中。我建议使用Python启动程序并执行pip作为带有-m开关的脚本。然后,您可以为特定的Python版本(如果安装了多个版本)安装车轮,并且脚本目录不必位于路径中。因此,打开命令行,导航(使用cd命令)到.whl文件所在的文件夹并输入:

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.

将3.6替换为Python版本,如果路径中出现所需的Python版本,则只需输入-3。使用活动虚拟环境:py -m pip安装your_whl_file.whl。

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

当然,您也可以通过这种方式从PyPI安装包。

py -3.6 -m pip install pygame

#12


0  

You can install the .whl file, using pip install filename. Though to use it in this form, it should be in the same directory as your command line, otherwise specify the complete filename, along with its address like pip install C:\Some\PAth\filename.

您可以使用pip安装文件名安装.whl文件。尽管在此表单中使用它,但它应该与命令行在同一个目录中,否则指定完整的文件名,以及它的地址,比如pip安装C:\一些\路径\文件名。

Also make sure the .whl file is of the same platform as you are using, do a python -V to find out which version of Python you are running and if it is win32 or 64, install the correct version according to it.

还要确保.whl文件与您正在使用的平台相同,做一个python -V,找出您正在运行的python版本,如果是win32或64,那么根据它安装正确的版本。

#13


0  

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

如果您无法使用PIP直接安装特定的包,请使用这种方法。

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

您可以从- https://www.lfd.uci.edu/~gohlke/pythonlibs/下载特定的.whl (wheel)包

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

CD(更改目录)到下载的包并通过- pip安装PACKAGENAME手动安装它。whl ex: pip安装ad3 - 2.1 cp27 - cp27m win32.whl

#14


-1  

On the MacOS, with pip installed via MacPorts into the MacPorts python2.7, I had to use @Dunes solution:

在MacOS上,通过MacPorts安装pip到MacPorts python2.7,我必须使用@Dunes解决方案:

sudo python -m pip install some-package.whl

Where python was replaced by the MacPorts python in my case, which is python2.7 or python3.5 for me.

在我的例子中,python被MacPorts python所取代,它是python2.7或python3.5。

The -m option is "Run library module as script" according to the manpage.

m选项是“运行库模块作为脚本”,根据manpage。

(I had previously run sudo port install py27-pip py27-wheel to install pip and wheel into my python 2.7 installation first.)

(我之前运行过sudo端口安装py27-pip py27-wheel,先将pip和wheel安装到python 2.7安装中。)

#1


702  

I just used the following which was quite simple. First open a console then cd to where you've downloaded your file like some-package.whl and use

我只是用了下面这个很简单的方法。首先打开一个控制台,然后cd到你下载文件的地方,比如某个包。whl和使用

pip install some-package.whl

Note: if pip.exe is not recognized, you may find it in the "Scripts" directory from where python has been installed. If pip is not installed, this page can help: How do I install pip on Windows?

注意:如果皮普。exe无法识别,您可以在python安装的“Scripts”目录中找到它。如果pip没有安装,这个页面可以提供帮助:如何在Windows上安装pip ?

Note: for clarification
If you copy the *.whl file to your local drive (ex. C:\some-dir\some-file.whl) use the following command line parameters --

注:如需澄清,请将*复制。whl文件到您的本地驱动器(例如C:\some-dir\some-file.whl)使用以下命令行参数——

pip install C:/some-dir/some-file.whl

#2


47  

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

要从轮上安装,请给它一个下载轮的目录。例如,要安装package_name.whl:

pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name

Make sure you have updated pip first to enable wheel support:

确保您已经更新了pip,以支持轮支持:

pip install --upgrade pip

#3


18  

I am in the same boat as the OP.

我和OP在同一条船上。

Using a Windows command prompt, from directory:

使用Windows命令提示符,从目录:

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.

将目录更改为whl所在的位置,它只告诉我“pip不被识别”。回到C:\Python34\Scripts>,然后使用上面的完整命令来提供“where/its/download”位置,它说需求“scikit_image-…-win32”。whl'看起来像文件名,但文件名不存在。

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.

因此,我在Python34/Scripts中删除了.whl的一个拷贝,再次运行相同的命令(使用—find-links=仍然转到另一个文件夹),这次它成功了。

#4


12  

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

你必须运行pip。从我的计算机上的命令提示符。我输入C:/ / pip2 Python27 /脚本。exe安装numpy

#5


9  

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

在伟大的Christoph Gohlke的网站上有几个文件版本。

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

当我从这个站点安装*时,我发现重要的一点是首先从Python控制台运行这个:

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).

这样你就知道应该为你的电脑安装哪个版本。选择错误的版本可能会导致软件包的安装失败(特别是如果您不使用正确的CPython标记,例如cp27)。

#6


7  

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:

在Windows上,您不能仅仅通过pip安装升级——升级pip,因为pip。exe正在使用中,将会有一个错误替换它。相反,您应该这样升级pip:

easy_install --upgrade pip

Then check the pip version:

然后检查pip版本:

pip --version

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

如果它显示6。x系列,有滚轮支撑。

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

只有这样,你才能安装这样的轮包:

pip install your-package.whl

#7


4  

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

要安装带有简单doubleclick文件的轮文件,您可以执行以下操作:

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

1)在管理员权限下运行命令行中的两个命令:

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.

或者,它们可以被复制到一个*中。bat文件并在属性中使用“作为管理员运行”复选框执行。

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

PS皮普。假设exe在路径中。

Update:

更新:

(1) Those can be combined in one line:

(1)可合并为一行:

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

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

(2) .bat文件的语法略有不同:

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.

详情请参阅我的博客文章。

#8


2  

To avoid having to download such files, you can try:

为了避免下载这些档案,你可以尝试:

pip install --use-wheel pillow

For more information, see this.

有关更多信息,请参见本文。

#9


1  

The only way I managed to install NumPy was as follows:

I downloaded NumPy from here https://pypi.python.org/pypi/numpy

我从这里下载了NumPy https://pypi.python.org/pypi/numpy

This Module

https://pypi.python.org/packages/d7/3c/d8b473b517062cc700575889d79e7444c9b54c6072a22189d1831d2fbbce/numpy-1.11.2-cp35-none-win32.whl#md5=e485e06907826af5e1fc88608d0629a2

Command execution from Python's installation path in PowerShell

PS C:\Program Files (x86)\Python35-32> .\python -m pip install C:/Users/MyUsername/Documents/Programs/Python/numpy-1.11.2-cp35-none-win32.whl
Processing c:\users\MyUsername\documents\programs\numpy-1.11.2-cp35-none-win32.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.2
PS C:\Program Files (x86)\Python35-32>

PS.: I installed it on Windows 10.

我把它安装在Windows 10上了。

#10


1  

What I did was first updating the pip by using the command: pip install --upgrade pip and then I also installed wheel by using command: pip install wheel and then it worked perfectly Fine. Hope it works for you I guess.

我所做的是首先使用命令来更新pip: pip安装——升级pip,然后我还使用命令安装了*:pip安装轮,然后它运行得非常好。希望对你有用。

#11


0  

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:

Windows上的新Python用户在安装过程中经常忘记将Python的\脚本目录添加到PATH变量中。我建议使用Python启动程序并执行pip作为带有-m开关的脚本。然后,您可以为特定的Python版本(如果安装了多个版本)安装车轮,并且脚本目录不必位于路径中。因此,打开命令行,导航(使用cd命令)到.whl文件所在的文件夹并输入:

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.

将3.6替换为Python版本,如果路径中出现所需的Python版本,则只需输入-3。使用活动虚拟环境:py -m pip安装your_whl_file.whl。

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

当然,您也可以通过这种方式从PyPI安装包。

py -3.6 -m pip install pygame

#12


0  

You can install the .whl file, using pip install filename. Though to use it in this form, it should be in the same directory as your command line, otherwise specify the complete filename, along with its address like pip install C:\Some\PAth\filename.

您可以使用pip安装文件名安装.whl文件。尽管在此表单中使用它,但它应该与命令行在同一个目录中,否则指定完整的文件名,以及它的地址,比如pip安装C:\一些\路径\文件名。

Also make sure the .whl file is of the same platform as you are using, do a python -V to find out which version of Python you are running and if it is win32 or 64, install the correct version according to it.

还要确保.whl文件与您正在使用的平台相同,做一个python -V,找出您正在运行的python版本,如果是win32或64,那么根据它安装正确的版本。

#13


0  

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

如果您无法使用PIP直接安装特定的包,请使用这种方法。

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

您可以从- https://www.lfd.uci.edu/~gohlke/pythonlibs/下载特定的.whl (wheel)包

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

CD(更改目录)到下载的包并通过- pip安装PACKAGENAME手动安装它。whl ex: pip安装ad3 - 2.1 cp27 - cp27m win32.whl

#14


-1  

On the MacOS, with pip installed via MacPorts into the MacPorts python2.7, I had to use @Dunes solution:

在MacOS上,通过MacPorts安装pip到MacPorts python2.7,我必须使用@Dunes解决方案:

sudo python -m pip install some-package.whl

Where python was replaced by the MacPorts python in my case, which is python2.7 or python3.5 for me.

在我的例子中,python被MacPorts python所取代,它是python2.7或python3.5。

The -m option is "Run library module as script" according to the manpage.

m选项是“运行库模块作为脚本”,根据manpage。

(I had previously run sudo port install py27-pip py27-wheel to install pip and wheel into my python 2.7 installation first.)

(我之前运行过sudo端口安装py27-pip py27-wheel,先将pip和wheel安装到python 2.7安装中。)