如何安装带有 .whl 文件的 Python 包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27885397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I install a Python package with a .whl file?
提问by e9t
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, alleviated much of the fuss for many other package installations). However, only .whl files are available.
我在我的 Windows 机器上安装 Python 包时遇到问题,我想用 Christoph Gohlke 的 Window 二进制文件安装它。(根据我的经验,这减轻了许多其他软件包安装的麻烦)。但是,只有 .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.
- This question is a duplicate with this question, which wasn't directly answered.
采纳答案by kpierce8
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 到你下载文件的地方,比如 some-package.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?
注意:如果 pip.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
回答by Burhan Khalid
First, make sure you have updated pip to enable wheel support:
首先,确保您已更新 pip 以启用轮子支持:
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
:
然后,要从轮子安装,请为其提供下载轮子的目录。例如,要安装package_name.whl
:
pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name
回答by Patrick
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/downloaded”位置,它说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.
所以我在 Python34/Scripts 中删除了 .whl 的副本,再次运行完全相同的命令(--find-links=
仍然转到另一个文件夹),这次它起作用了。
回答by Steel
You have to run pip.exe from the command prompt on my computer.
I type C:/Python27/Scripts/pip2.exe install numpy
您必须在我的计算机上从命令提示符运行 pip.exe。我打字C:/Python27/Scripts/pip2.exe install numpy
回答by Rockallite
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 install --upgrade 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
回答by elachell
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)。
回答by axil
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:
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.
2) 或者,也可以将它们复制到wheel.bat
文件中并使用属性中的“以管理员身份运行”复选框来执行。
PS pip.exe is assumed to be in the PATH.
PS pip.exe 假定在 PATH 中。
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 postfor details.
有关详细信息,请参阅我的博客文章。
回答by andyw
回答by Vladimir
The only way I managed to install NumPy was as follows:
我设法安装 NumPy 的唯一方法如下:
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
在PowerShell 中从 Python 的安装路径执行命令
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.
PS.:我在 Windows 10 上安装了它。
回答by Aklank Jain
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
.
您可以使用 .whl 文件安装 .whl 文件pip install filename
。尽管要以这种形式使用它,它应该与您的命令行在同一目录中,否则指定完整的文件名及其地址,如pip install C:\Some\PAth\filename
.
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 文件与您正在使用的平台相同,执行 apython -V
以找出您正在运行的 Python 版本,如果它是 win32 或 64,请根据它安装正确的版本。