Python 车轮文件安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28002897/
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
Wheel file installation
提问by balloneij
How do I install a .whl file? I have the Wheel library but I don't know how to use it to install those files. I have the .whl file but I don't know how to run it. Please help.
如何安装 .whl 文件?我有 Wheel 库,但我不知道如何使用它来安装这些文件。我有 .whl 文件,但我不知道如何运行它。请帮忙。
采纳答案by Martijn Pieters
You normally use a tool like pip
to install wheels. Leave it to the tool to discover and download the file if this is for a project hosted on PyPI.
您通常使用诸如pip
安装轮子之类的工具。如果这是用于 PyPI 上托管的项目,则将其留给工具来发现和下载文件。
For this to work, you do need to install the wheel
package:
为此,您需要安装wheel
软件包:
pip install wheel
You can then tell pip
to install the project (and it'll download the wheel if available), or the wheel file directly:
然后,您可以告诉pip
安装项目(如果可用,它将下载轮子)或直接安装轮子文件:
pip install project_name # discover, download and install
pip install wheel_file.whl # directly install the wheel
The wheel
module, once installed, also is runnable from the command line, you can use this to install already-downloaded wheels:
该wheel
模块一旦安装,也可以从命令行运行,您可以使用它来安装已经下载的轮子:
python -m wheel install wheel_file.whl
Also see the wheel
project documentation.
另请参阅wheel
项目文档。
回答by Sam_Sadana
If you already have a wheel file (.whl) on your pc, then just go with the following code:
如果您的电脑上已经有一个轮文件 (.whl),那么只需使用以下代码:
cd ../user
pip install file.whl
If you want to download a file from web, and then install it, go with the following in command line:
如果要从 Web 下载文件,然后安装它,请在命令行中执行以下操作:
pip install package_name
or, if you have the url:
或者,如果您有网址:
pip install http//websiteurl.com/filename.whl
This will for sure install the required file.
这肯定会安装所需的文件。
Note: I had to type pip2 instead of pip while using Python 2.
注意:在使用 Python 2 时,我必须输入 pip2 而不是 pip。