How do I install a Python package with a .whl file

2018-12-31 05:48发布

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

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

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

But how do I install .whl files?

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.

15条回答
十年一品温如言
2楼-- · 2018-12-31 06:41

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

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.

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

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

查看更多
姐姐魅力值爆表
3楼-- · 2018-12-31 06:42

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:

easy_install --upgrade pip

Then check the pip version:

pip --version

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

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

pip install your-package.whl
查看更多
素衣白纱
4楼-- · 2018-12-31 06:44

To install from wheel, give it the directory where the wheel is downloaded. For example, to install 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
查看更多
登录 后发表回答