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

本文翻译自:How do I install a Python package with a .whl file?

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. 我在Windows机器上安装Python软件包(特别是JPype1 0.5.7)时遇到问题,并且想用Christoph Gohlke的Window二进制文件安装它。 (Which, to my experience, alleviated much of the fuss for many other package installations.) (根据我的经验,这减轻了许多其他软件包安装的麻烦。)

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. 我已经找到了车轮上的文档 ,但是它们在解释如何安装.whl文件时似乎并不那么简单。
  • This question is a duplicate with this question , which wasn't directly answered. 该问题与该问题重复,但未直接回答。

#1楼

参考:https://stackoom.com/question/1t0GT/如何安装带有-whl文件的Python软件包


#2楼

To install from wheel, give it the directory where the wheel is downloaded. 要从wheel安装,请给它提供下载wheel的目录。 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 install --upgrade pip

#3楼

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. 注意:如果无法识别pip.exe,则可以在安装python的“脚本”目录中找到它。 If pip is not installed, this page can help: How do I install pip on Windows? 如果未安装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

#4楼

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'. 将目录更改为whl所在的目录,它只是告诉我“无法识别点子”。 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 . 返回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=仍转到另一个文件夹),这一次它起作用了。


#5楼

You have to run pip.exe from the command prompt on my computer. 您必须从我的计算机上的命令提示符处运行pip.exe。 I type C:/Python27/Scripts/pip2.exe install numpy 我输入C:/Python27/Scripts/pip2.exe install numpy


#6楼

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. 在Windows上,您不能仅使用pip install --upgrade pip pip.exe pip install --upgrade pip升级,因为pip.exe正在使用中,替换它会出错。 Instead, you should upgrade pip like this: 相反,您应该像这样升级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
发布了0 篇原创文章 · 获赞 137 · 访问量 84万+

猜你喜欢

转载自blog.csdn.net/xfxf996/article/details/105425704