标签归档:python-wheel

pip安装中“ X的构建车轮失败”是什么意思?

问题:pip安装中“ X的构建车轮失败”是什么意思?

在SO上,这是一个真正流行的问题,但是我看过的所有答案中,没有一个能清楚地说明此错误的真正含义以及发生的原因。

造成混乱的原因之一是,当您(例如)这样做时pip install pycparser,您首先会得到以下错误:

Failed building wheel for pycparser

然后出现以下消息,说明该软件包是:

Successfully installed pycparser-2.19


# pip3 install pycparser

Collecting pycparser
  Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
Building wheels for collected packages: pycparser
  Running setup.py bdist_wheel for pycparser ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g_v28hpp/pycparser/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-__w_f6p0 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ...
    File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2349, in resolve
      module = __import__(self.module_name, fromlist=['__name__'], level=0)
  ModuleNotFoundError: No module named 'wheel.bdist_wheel'

  ----------------------------------------
  Failed building wheel for pycparser
  Running setup.py clean for pycparser
Failed to build pycparser
Installing collected packages: pycparser
  Running setup.py install for pycparser ... done
Successfully installed pycparser-2.19

这里发生了什么?

(我想了解如何发生某些故障但仍然可以安装,以及是否可以信任此软件包正常运行?)

到目前为止,我已经找到了最好的部分原因是这个

This is a truly popular question here at SO, but none of the many answers I have looked at, clearly explain what this error really mean, and why it occurs.

One source of confusion, is that when (for example) you do pip install pycparser, you first get the error:

Failed building wheel for pycparser

which is then followed by the message that the package was:

Successfully installed pycparser-2.19.


# pip3 install pycparser

Collecting pycparser
  Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
Building wheels for collected packages: pycparser
  Running setup.py bdist_wheel for pycparser ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-g_v28hpp/pycparser/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-__w_f6p0 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ...
    File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2349, in resolve
      module = __import__(self.module_name, fromlist=['__name__'], level=0)
  ModuleNotFoundError: No module named 'wheel.bdist_wheel'

  ----------------------------------------
  Failed building wheel for pycparser
  Running setup.py clean for pycparser
Failed to build pycparser
Installing collected packages: pycparser
  Running setup.py install for pycparser ... done
Successfully installed pycparser-2.19

What is going on here?

(I would like to understand how something can fail but still get installed and whether you can trust this package functioning correctly?)

So far the best partial explanation I have found is this.


回答 0

(这里是点子维护者!)

如果包装不是车轮,则pip尝试为其构建一个车轮(通过setup.py bdist_wheel)。如果由于任何原因导致安装失败,您将收到“ pycparser的建筑轮子故障”消息,并且pip退回到直接安装(通过setup.py install)。

装好轮子后,pip可以通过正确打开包装来安装轮子。pip尝试尽可能多地通过轮子安装软件包。这是由于使用滚轮的各种优势(例如更快的安装,可缓存的,不再执行代码等)。


您在这里的错误消息是由于wheel缺少软件包,其中包含构建轮子所需的逻辑setup.py bdist_wheel。(pip install wheel可以解决该问题。)


以上是当前默认的旧行为;我们会默认在将来的某个时间切换到PEP 517,为此我们将转到基于标准的流程。我们还为此提供了隔离的版本,因此,默认情况下,您会在这些环境中安装滚轮。:)

(pip maintainer here!)

If the package is not a wheel, pip tries to build a wheel for it (via setup.py bdist_wheel). If that fails for any reason, you get the “Failed building wheel for pycparser” message and pip falls back to installing directly (via setup.py install).

Once we have a wheel, pip can install the wheel by unpacking it correctly. pip tries to install packages via wheels as often as it can. This is because of various advantages of using wheels (like faster installs, cache-able, not executing code again etc).


Your error message here is due to the wheel package being missing, which contains the logic required to build the wheels in setup.py bdist_wheel. (pip install wheel can fix that.)


The above is the legacy behavior that is currently the default; we’ll switch to PEP 517 by default, sometime in the future, moving us to a standards-based process for this. We also have isolated builds for that so, you’d have wheel installed in those environments by default. :)


回答 1

昨天,我遇到了同样的错误: Failed building wheel for hddfancontrol跑步时pip3 install hddfancontrol。结果是Failed to build hddfancontrol。原因是error: invalid command 'bdist_wheel'Running setup.py bdist_wheel for hddfancontrol ... error。通过运行以下命令修复了该错误:

 pip3 install wheel

(从这里开始。)

另外,也可以从此处直接下载“ wheel” 。下载后,可以通过运行以下命令进行安装:

pip3 install "/the/file_path/to/wheel-0.32.3-py2.py3-none-any.whl"

Yesterday, I got the same error: Failed building wheel for hddfancontrol when I ran pip3 install hddfancontrol. The result was Failed to build hddfancontrol. The cause was error: invalid command 'bdist_wheel' and Running setup.py bdist_wheel for hddfancontrol ... error. The error was fixed by running the following:

 pip3 install wheel

(From here.)

Alternatively, the “wheel” can be downloaded directly from here. When downloaded, it can be installed by running the following:

pip3 install "/the/file_path/to/wheel-0.32.3-py2.py3-none-any.whl"

回答 2

从那以后,似乎没有人提到我自己。我自己解决上述问题是最常见的,以确保禁用缓存使用副本:pip install <package> --no-cache-dir

Since, nobody seem to mention this apart myself. My own solution to the above problem is most often to make sure to disable the cached copy by using: pip install <package> --no-cache-dir.


回答 3

从程序包部署的角度解决此问题可能会有所帮助。

那里有许多教程介绍了如何将程序包发布到PyPi。以下是我使用过的几对;

中型
真正的python

我的经验是,这些教程大多数都只使用源代码的.tar,而不使用转盘。因此,在安装使用这些教程创建的软件包时,我收到了“无法构建轮子”错误。

后来我在PyPi上找到了指向Python软件基金会的文档PSF Docs的链接。我发现它们的设置和构建过程略有不同,并且确实包括构建wheel文件。

使用正式记录的方法后,安装软件包时不再收到错误。

因此,错误可能只是开发人员如何打包和部署项目的问题。我们当中没有一个人天生就知道如何使用PyPi,如果它们是在错误的教程上发生的,那么您可以填补空白。

我敢肯定这不是错误的唯一原因,但我敢打赌这是主要原因。

It might be helpful to address this question from a package deployment perspective.

There are many tutorials out there that explain how to publish a package to PyPi. Below are a couple I have used;

medium
real python

My experience is that most of these tutorials only have you use the .tar of the source, not a wheel. Thus, when installing packages created using these tutorials, I’ve received the “Failed to build wheel” error.

I later found the link on PyPi to the Python Software Foundation’s docs PSF Docs. I discovered that their setup and build process is slightly different, and does indeed included building a wheel file.

After using the officially documented method, I no longer received the error when installing my packages.

So, the error might simply be a matter of how the developer packaged and deployed the project. None of us were born knowing how to use PyPi, and if they happened upon the wrong tutorial — well, you can fill in the blanks.

I’m sure that is not the only reason for the error, but I’m willing to bet that is a major reason for it.


回答 4

试试这个:

sudo apt-get install libpcap-dev libpq-dev

当我安装了这两个时,它对我有用。

有关更多信息,请参见此处的链接。

Try this:

sudo apt-get install libpcap-dev libpq-dev

It has worked for me when I have installed these two.

See the link here for more information


回答 5

在Ubuntu 18.04上,我遇到了此问题,因为的apt软件包wheel不包含wheel命令。我认为pip尝试导入wheelpython包,如果成功,则假定wheel命令也可用。Ubuntu打破了这一假设。

apt python3代码包的名称为python3-wheel。这是自动安装的,因为python3-pip建议您这样做。

apt python3 wheel命令包的名称为python-wheel-common。安装此工具也可以为我解决“建筑轮子故障”错误。

On Ubuntu 18.04, I ran into this issue because the apt package for wheel does not include the wheel command. I think pip tries to import the wheel python package, and if that succeeds assumes that the wheel command is also available. Ubuntu breaks that assumption.

The apt python3 code package is named python3-wheel. This is installed automatically because python3-pip recommends it.

The apt python3 wheel command package is named python-wheel-common. Installing this too fixes the “failed building wheel” errors for me.


回答 6

当我尝试安装pip install django-imagekit时,出现了相同的消息。因此,我运行了pip install wheel(我安装了python 2.7),然后重新运行了pip install django-imagekit,它开始工作了。谢谢

I got the same message when I tried to install pip install django-imagekit. So I ran pip install wheel (I had python 2.7) and then I reran pip install django-imagekit and it worked. Thanks


回答 7

我想补充一点,如果您的系统上只有Python3,则需要开始使用pip3而不是pip。

您可以使用以下命令安装pip3;

sudo apt install python3-pip -y

之后,您可以尝试安装所需的软件包。

sudo pip3 install <package>

I would like to add that if you only have Python3 on your system then you need to start using pip3 instead of pip.

You can install pip3 using the following command;

sudo apt install python3-pip -y

After this you can try to install the package you need with;

sudo pip3 install <package>

回答 8

错误:

系统:AWS EC2实例(T2小)

问题:通过安装opencv python时

pip3 install opencv-python

  Problem with the CMake installation, aborting build. CMake executable is cmake
  
  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python

什么对我有用

pip3 install --upgrade pip setuptools wheel

在此之后,您仍然可能会收到休闲错误错误

    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

安装libgl为我解决了错误。

sudo apt update
sudo apt install libgl1-mesa-glx

希望这可以帮助

Error :

System : aws ec2 instance (t2 small)

issue : while installing opencv python via

pip3 install opencv-python

  Problem with the CMake installation, aborting build. CMake executable is cmake
  
  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python

What worked for me

pip3 install --upgrade pip setuptools wheel

After this you still might received fallowing error error

    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Installing libgl solved the error for me.

sudo apt update
sudo apt install libgl1-mesa-glx

Hope this helps


回答 9

安装Brotli时遇到相同的问题

错误

Failed building wheel for Brotli

我通过.whl此处下载文件 并使用以下命令进行安装来解决了该问题

C:\Users\{user_name}\Downloads>pip install Brotli-1.0.9-cp39-cp39-win_amd64.whl

I had the same problem while installing Brotli

ERROR

Failed building wheel for Brotli

I solved it by downloading the .whl file from here and installing it using the below command

C:\Users\{user_name}\Downloads>pip install Brotli-1.0.9-cp39-cp39-win_amd64.whl

回答 10

这可能对您有帮助!….

卸载pycparser:

pip uninstall pycparser

重新安装pycparser:

pip install pycparser

我在安装termcolor时遇到了同样的错误,并通过重新安装进行了修复。

This may Help you ! ….

Uninstalling pycparser:

pip uninstall pycparser

Reinstall pycparser:

pip install pycparser

I got same error while installing termcolor and I fixed it by reinstalling it .


车轮文件安装

问题:车轮文件安装

如何安装.whl文件?我有Wheel库,但是我不知道如何使用它来安装那些文件。我有.whl文件,但我不知道如何运行它。请帮忙。

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.


回答 0

通常,您会使用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项目文档

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.

For this to work, you do need to install the wheel package:

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 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:

python -m wheel install wheel_file.whl

Also see the wheel project documentation.


回答 1

如果您的电脑上已经有一个wheel文件(.whl),则只需执行以下代码:

cd ../user
pip install file.whl

如果要从Web下载文件然后安装,请在命令行中执行以下操作:

pip install package_name

或者,如果您具有网址:

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

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

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

If you already have a wheel file (.whl) on your pc, then just go with the following code:

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:

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中创建轮子?

问题:为什么我不能在python中创建轮子?

这是我正在运行的命令:

$ python setup.py bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'

$ pip --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)

$ python -c "import setuptools; print(setuptools.__version__)"
2.1

$ python --version
Python 3.4.1

$ which python
/usr/local/bin/python

此外,我正在使用自制的python运行Mac

这是我的setup.py脚本:https : //gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd

我快要疯了-我不知道为什么这不起作用。

Here are the commands I am running:

$ python setup.py bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'

$ pip --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)

$ python -c "import setuptools; print(setuptools.__version__)"
2.1

$ python --version
Python 3.4.1

$ which python
/usr/local/bin/python

Also, I am running a mac with homebrewed python

Here is my setup.py script: https://gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd

I’m going absolutely crazy — I can’t figure out why this wouldn’t be working.


回答 0

首先安装wheel软件包

pip install wheel

文档并不太清楚,但是“ wheel项目为setuptools提供了bdist_wheel命令”实际上是指“ wheel package …”

Install the wheel package first:

pip install wheel

The documentation isn’t overly clear on this, but “the wheel project provides a bdist_wheel command for setuptools” actually means “the wheel package…”.


回答 1

我也遇到了错误信息 invalid command 'bdist_wheel'

原来包setup.py使用的是distutils而不是setuptools。如下进行更改可以使我制造轮子。

#from distutils.core import setup
from setuptools import setup

I also ran into the error message invalid command 'bdist_wheel'

It turns out the package setup.py used distutils rather than setuptools. Changing it as follows enabled me to build the wheel.

#from distutils.core import setup
from setuptools import setup

回答 2

也更新您的setuptools。

pip install setuptools --upgrade

如果仍然失败,则可以尝试使用其他--force标志。

Update your setuptools, too.

pip install setuptools --upgrade

If that fails too, you could try with additional --force flag.


回答 3

在以前无法正常工作之后,我也突然遇到了这种情况,这是因为我在virtualenv中,wheel没有安装在virtualenv中。

I also ran into this all of a sudden, after it had previously worked, and it was because I was inside a virtualenv, and wheel wasn’t installed in the virtualenv.


回答 4

更新您的pip第一个:

pip install --upgrade pip

对于Python 3:

pip3 install --upgrade pip

Update your pip first:

pip install --upgrade pip

for Python 3:

pip3 install --upgrade pip

回答 5

也可能是您只有python3系统。因此,您已经通过pip3 install安装了必要的软件包,例如pip3 install wheel

您需要专门使用python3构建自己的东西。

python3 setup.py sdist
python3 setup.py bdist_wheel

干杯。

It could also be that you have a python3 system only. You therefore have installed the necessary packages via pip3 install , like pip3 install wheel.

You’ll need to build your stuff using python3 specifically.

python3 setup.py sdist
python3 setup.py bdist_wheel

Cheers.


回答 6

提出另一个答案:尝试检查您的PYTHONPATH

首先,尝试重新安装wheel

pip install wheel

这应该告诉您车轮安装在哪里,例如:

Requirement already satisfied: wheel in /usr/local/lib/python3.5/dist-packages

然后将wheel的位置添加到您的PYTHONPATH

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/wheel

现在,构建轮子应该可以正常工作。

python setup.py bdist_wheel

Throwing in another answer: Try checking your PYTHONPATH.

First, try to install wheel again:

pip install wheel

This should tell you where wheel is installed, eg:

Requirement already satisfied: wheel in /usr/local/lib/python3.5/dist-packages

Then add the location of wheel to your PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/wheel

Now building a wheel should work fine.

python setup.py bdist_wheel

回答 7

我尝试了这里所说的一切,没有任何运气,但找到了解决方法。运行此命令后(失败):bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

转到工具制作的临时目录(在最后一个命令的输出中给出),然后执行python setup.py bdist_wheel。该.whl文件位于dist文件夹中。

I tried everything said here without any luck, but found a workaround. After running this command (and failing) : bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

Go to the temporary directory the tool made (given in the output of the last command), then execute python setup.py bdist_wheel. The .whl file is in the dist folder.


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

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

我在Windows机器上安装Python软件包时遇到问题,想与Christoph Gohlke的Window二进制文件一起安装。(根据我的经验,这减轻了许多其他软件包安装的麻烦)。但是,仅.whl文件可用。

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

但是,如何安装.whl文件?

笔记

  • 我已经找到了车轮上的文档,但是它们在解释如何安装.whl文件时似乎并不那么简单。
  • 该问题与该问题重复,但未直接回答。

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.

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.

回答 0

我只是使用了以下非常简单的内容。首先打开一个控制台,然后打开cd到您下载文件的位置,例如some-package.whl并使用

pip install some-package.whl

注意:如果无法识别pip.exe,则可以在安装python的“脚本”目录中找到它。如果未安装pip,则此页面可以提供帮助: 如何在Windows上安装pip?

注意:为澄清起见,
如果将*.whl文件复制到本地驱动器(例如C:\ some-dir \ some-file.whl),请使用以下命令行参数-

pip install C:/some-dir/some-file.whl

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

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?

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 —

pip install C:/some-dir/some-file.whl

回答 1

首先,请确保您已更新点子以启用滚轮支持:

pip install --upgrade pip

然后,要从wheel安装,请给它提供下载wheel的目录。例如,安装package_name.whl

pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name

First, make sure you have updated pip to enable wheel support:

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:

pip install --use-wheel --no-index --find-links=/where/its/downloaded package_name

回答 2

我和OP在同一条船上。

使用Windows命令提示符,从目录:

C:\Python34\Scripts>
pip install wheel

似乎有效。

将目录更改为whl所在的目录,它只是告诉我“无法识别点子”。回到C:\Python34\Scripts>上面,然后使用上面的完整命令提供“ where / its / downloaded”位置Requirement 'scikit_image-...-win32.whl' looks like a filename, but the filename does not exist

因此,我在Python34 / Scripts中放了一个.whl副本,再次运行了完全相同的命令(--find-links=仍然转到另一个文件夹),这一次它起作用了。

I am in the same boat as the OP.

Using a Windows command prompt, from directory:

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.

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.


回答 3

Christoph Gohlke的站点上有多个文件版本。

从该站点安装车轮时,我发现重要的一点是首先从Python控制台运行此车轮:

import pip
print(pip.pep425tags.get_supported())

这样您就知道应该为计算机安装哪个版本。选择错误的版本可能会导致软件包安装失败(尤其是如果您没有使用正确的CPython标记,例如cp27)。

There are several file versions on the great Christoph Gohlke’s site.

Something I have found important when installing wheels from this site is to first run this from the Python console:

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


回答 4

您必须从我的计算机上的命令提示符处运行pip.exe。我输入C:/Python27/Scripts/pip2.exe install numpy

You have to run pip.exe from the command prompt on my computer. I type C:/Python27/Scripts/pip2.exe install numpy


回答 5

在Windows上,您不能仅使用进行升级pip install --upgrade pip,因为pip.exe正在使用,替换它会出错。相反,您应该pip像这样升级:

easy_install --upgrade pip

然后检查pip版本:

pip --version

如果显示 6.x系列,则有车轮支撑。

只有这样,您才能安装以下车轮套件:

pip install your-package.whl

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

回答 6

为了能够通过简单的双击安装wheel文件,您可以执行以下操作之一:

1)在命令行下以管理员权限运行两个命令:

assoc .whl=pythonwheel
ftype pythonwheel=cmd /c pip.exe install "%1" ^& pause

2)或者,可以将它们复制到wheel.bat文件中,并通过属性中的“以管理员身份运行”复选框来执行。

PS pip.exe假定位于PATH中。

更新:

(1)可以合并为一行:

assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%1" ^& pause

(2).bat文件的语法略有不同:

assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%%1" ^& pause

还可以使其输出更加详细:

@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

有关详细信息,请参见我的博客文章

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:

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.

PS pip.exe is assumed to be in the PATH.

Update:

(1) Those can be combined in one line:

assoc .whl=pythonwheel& ftype pythonwheel=cmd /c pip.exe install -U "%1" ^& pause

(2) Syntax for .bat files is slightly different:

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 post for details.


回答 7

编辑:这不再是画中画的一部分

为避免下载此类文件,您可以尝试:

pip install --use-wheel pillow

有关更多信息,请参见this

EDIT: THIS NO LONGER IS A PART OF PIP

To avoid having to download such files, you can try:

pip install --use-wheel pillow

For more information, see this.


回答 8

如果您无法直接使用PIP安装特定的软件包。

您可以.whl-https://www.lfd.uci.edu/~gohlke/pythonlibs/下载特定的(wheel)软件包

CD(更改目录)到下载的软件包,并通过
pip install PACKAGENAME.whl
-ex 手动安装:
pip install ad3‑2.1‑cp27‑cp27m‑win32.whl

In-case if you unable to install specific package directly using PIP.

You can download a specific .whl (wheel) package from – https://www.lfd.uci.edu/~gohlke/pythonlibs/

CD (Change directory) to that downloaded package and install it manually by –
pip install PACKAGENAME.whl
ex:
pip install ad3‑2.1‑cp27‑cp27m‑win32.whl


回答 9

我设法安装NumPy的唯一方法如下:

我从这里下载了NumPy https://pypi.python.org/pypi/numpy

这个模块

https://pypi.python.org/packages/d7/3c/d8b473b517062cc700575889d79e7444c9b54c6072a22189d1831d2fbbce/numpy-1.11.2-cp35-none-win32.whl#md5=e485e06907826af5e1fc88608d0629a2

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 .:我在Windows 10上安装了它。

The only way I managed to install NumPy was as follows:

I downloaded NumPy from here 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

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.


回答 10

您可以使用来安装.whl文件pip install filename。尽管要以这种形式使用它,但它应该与命令行位于同一目录中,否则请指定完整的文件名以及其地址(例如)pip install C:\Some\PAth\filename

另外,请确保.whl文件与您使用的平台处于同一平台,执行a python -V找出您正在运行的Python版本,如果它是win32或64,则根据其安装正确的版本。

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.

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.


回答 11

我要做的是先使用命令更新点子: pip install --upgrade pip然后使用命令安装轮pip install wheel,然后完美地工作了。

希望它对您有用。

What I did was first updating the pip by using the command: pip install --upgrade pip and then I also installed wheel by using command: pip install wheel and then it worked perfectly Fine.

Hope it works for you I guess.


回答 12

Windows上的新Python用户通常会在安装过程中忘记将Python的\ Scripts目录添加到PATH变量中。我建议使用Python启动器,并通过-m开关将pip作为脚本执行。然后,您可以安装特定Python版本的轮子(如果已安装多个版本),并且Scripts目录不必位于PATH中。因此,打开命令行,(使用cd命令)导航到.whl文件所在的文件夹,然后输入:

py -3.6 -m pip install your_whl_file.whl

3.6您的Python版本替换,或者输入-3所需的Python版本是否首先出现在PATH中。并在活跃的虚拟环境中:py -m pip install your_whl_file.whl

当然,您也可以通过这种方式从PyPI安装软件包,例如

py -3.6 -m pip install pygame

New Python users on Windows often forget to add Python’s \Scripts directory to the PATH variable during the installation. I recommend to use the Python launcher and execute pip as a script with the -m switch. Then you can install the wheels for a specific Python version (if more than one are installed) and the Scripts directory doesn’t have to be in the PATH. So open the command line, navigate (with the cd command) to the folder where the .whl file is located and enter:

py -3.6 -m pip install your_whl_file.whl

Replace 3.6 by your Python version or just enter -3 if the desired Python version appears first in the PATH. And with an active virtual environment: py -m pip install your_whl_file.whl.

Of course you can also install packages from PyPI in this way, e.g.

py -3.6 -m pip install pygame

回答 13

我会建议您如何安装.whl文件的确切方法。最初我遇到很多问题,但是后来我解决了,这是安装.whl文件的技巧。

正确地遵循步骤以获取模块导入

  1. 确保.whl文件保存在python 2.7 / 3.6 / 3.7 / ..文件夹中。最初,当您下载.whl文件时,该文件保留在下载文件夹中,我的建议是更改文件夹。它使安装文件更加容易。
  2. 打开命令提示符,然后输入以下内容,打开保存文件的文件夹:

cd c:\ python 3.7

3.现在,输入下面写的命令

>py -3.7(version name) -m pip install (file name).whl
  1. 单击输入,并确保以正确的文件名输入当前正在使用的版本。

  2. 按下Enter键后,等待几分钟,文件将被安装,您将能够导入特定的模块。

  3. 为了检查模块是否成功安装,请以空闲状态导入模块并进行检查。

谢谢:)

I would be suggesting you the exact way how to install .whl file. Initially I faced many issues but then I solved it, Here is my trick to install .whl files.

Follow The Steps properly in order to get a module imported

  1. Make sure your .whl file is kept in the python 2.7/3.6/3.7/.. folder. Initially when you download the .whl file the file is kept in downloaded folder, my suggestion is to change the folder. It makes it easier to install the file.
  2. Open command prompt and open the folder where you have kept the file by entering

cd c:\python 3.7

3.Now, enter the command written below

>py -3.7(version name) -m pip install (file name).whl
  1. Click enter and make sure you enter the version you are currently using with correct file name.

  2. Once you press enter, wait for few minutes and the file will be installed and you will be able to import the particular module.

  3. In order to check if the module is installed successfully, import the module in idle and check it.

Thank you:)


回答 14

下载包(.whl)。

将文件放在python目录的script文件夹中

C:\Python36\Scripts

使用命令提示符安装软件包。

C:\Python36\Scripts>pip install package_name.whl

Download the package (.whl).

Put the file inside the script folder of python directory

C:\Python36\Scripts

Use the command prompt to install the package.

C:\Python36\Scripts>pip install package_name.whl

回答 15

在MacOS上(pip通过MacPorts安装到MacPorts python2.7中),我不得不使用@Dunes解决方案:

sudo python -m pip install some-package.whl

python在我的情况下,在哪里被MacPorts python取代了,python2.7或者是python3.5对我对。

-m根据联机帮助页选项为“将库模块作为脚本运行”。

(我以前曾运行sudo port install py27-pip py27-wheel过安装程序,pip然后先wheel进入python 2.7安装程序。)

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