148

如何安装 .whl 文件?

我有轮子库,但我不知道如何使用它来安装这些文件。我有 .whl 文件,但我不知道如何运行它。

4

3 回答 3

194

您通常使用pip安装轮子之类的工具。如果这是用于托管在 PyPI 上的项目,则将其留给工具来发现和下载文件。

为此,您需要安装wheel软件包:

pip install wheel

然后,您可以告诉pip安装项目(如果可用,它将下载轮子),或直接安装轮子文件:

pip install project_name  # discover, download and install
pip install wheel_file.whl  # directly install the wheel

wheel模块一旦安装,也可以从命令行运行,您可以使用它来安装已经下载的轮子:

python -m wheel install wheel_file.whl

另请参阅wheel项目文档

于 2015-01-17T18:40:03.143 回答
28

如果您的 PC 上已经有一个 wheel 文件 (.whl),那么只需使用以下代码:

cd ../user
pip install file.whl

如果您想从 Web 下载文件,然后安装它,请在命令行中使用以下命令:

pip install package_name

或者,如果您有 URL:

pip install http//websiteurl.com/filename.whl

这肯定会安装所需的文件。

注意:在使用 Python 2 时,我必须输入 pip2 而不是 pip。

于 2018-05-15T03:27:43.153 回答
4

您可以按照以下命令在本地系统中使用 wheel 文件进行安装:

pip install /users/arpansaini/Downloads/h5py-3.0.0-cp39-cp39-macosx_10_9_x86_64.whl
于 2021-02-24T07:49:16.973 回答