为什么 python setup.py 在 Travis CI 上说无效命令“bdist_wheel”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34819221/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:34:03  来源:igfitidea点击:

Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?

pythontravis-cisetup.pypypi

提问by nokome

My Python package has a setup.pywhich builds fine locally on Ubuntu Trusty and on a fresh Vagrant Ubuntu Trusty VM when I provision it like this:

我的 Python 包有一个setup.py在 Ubuntu Trusty 和新的 Vagrant Ubuntu Trusty VM 上本地构建良好,当我像这样配置它时:

sudo apt-get install python python-dev --force-yes --assume-yes --fix-broken
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
sudo -H pip install setuptools wheel virtualenv --upgrade

But when I do the same on a Travis CI Trusty Beta VM:

但是当我在 Travis CI Trusty Beta VM 上做同样的事情时:

- sudo apt-get install python python-dev --force-yes --assume-yes --fix-broken
- curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
- sudo -H pip install setuptools wheel virtualenv --upgrade

I get:

我得到:

python2.7 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'

This Why can I not create a wheel in python?is related but note I am installing wheel and upgrading setuptools.

为什么我不能在 python 中创建一个轮子?是相关的,但请注意我正在安装轮子并升级 setuptools。

采纳答案by nokome

This problem is due to:

这个问题是由于:

  • an old version of pip (6.1.1) being installed for Python 2.7
  • multiple copies of Python 2.7 installed on the Trusty Beta image
  • a different location for Python 2.7 being used for sudo
  • 为 Python 2.7 安装了旧版本的 pip (6.1.1)
  • 安装在 Trusty Beta 映像上的 Python 2.7 的多个副本
  • 用于 Python 2.7 的不同位置 sudo

It's all a bit complicated and better explained here https://github.com/travis-ci/travis-ci/issues/4989.

这一切都有些复杂,这里有更好的解释https://github.com/travis-ci/travis-ci/issues/4989

My solution was to install with user travisinstead of sudo:

我的解决方案是与用户一起安装travis而不是sudo

- pip2.7 install --upgrade --user travis pip setuptools wheel virtualenv

回答by frmdstryr

Had to install the wheelpackage. Everything was up to date but still giving the error.

必须安装wheel软件包。一切都是最新的,但仍然给出错误。

pip install wheel

then

然后

python setup.py bdist_wheel 

Worked without issues.

工作没有问题。

回答by typelogic

This error is weird as many proposed answers and got mixed solutions. I tried them, add them. It was only when I added pip install --upgrade pipfinally removed the error for me. But I have no time to isolate which is which,so this is just fyi.

这个错误很奇怪,因为许多建议的答案和混合的解决方案。我试过了,添加它们。只有当我添加时,pip install --upgrade pip终于为我消除了错误。但我没有时间去区分哪个是哪个,所以这只是仅供参考。

回答by Kasramvd

If you already have all the required modules installed you probably need to import the setuptoolsmodule in your setup.pyfile. So just add the following line at the leading of setup.pyfile.

如果您已经安装了所有必需的模块,则可能需要setuptoolssetup.py文件中导入该模块。所以只需在setup.py文件的开头添加以下行。

import setuptools
from distutils.core import setup
# other imports and setups

This is also mentioned in wheel's documentation. https://wheel.readthedocs.io/en/stable/#usage

车轮的文档中也提到了这一点。https://wheel.readthedocs.io/en/stable/#usage

回答by Jerther

I already had wheelinstalled so I tried to uninstall and reinstall, and it fixed the issue:

我已经wheel安装了,所以我尝试卸载并重新安装,它解决了问题:

pip uninstall wheel
pip install wheel

Weird...

奇怪的...

回答by 7029279

My fix was apt install python3-dev

我的解决方法是 apt install python3-dev

回答by Nathaniel Gentile

pip install wheel

worked for me, but you can also add this

为我工作,但你也可以添加这个

setup(
    ...
    setup_requires=['wheel']
)

to setup.py and save yourself a pip install command

到 setup.py 并保存一个 pip install 命令

回答by Shubham Laddha

Try modifying the setup.py file by importing setup from setuptools instead of distutils.core

尝试通过从 setuptools 而不是 distutils.core 导入 setup 来修改 setup.py 文件

回答by Dmitri Zaitsev

Not related to Travis CI but I ran into similar problem trying to install jupyteron my Mac OSX 10.8.5, and none of the other answers was of help. The problem was caused by building the "wheel" for the package called pyzmq, with error messages filling hundreds of pages.

与 Travis CI 无关,但我在尝试jupyter在 Mac OSX 10.8.5 上安装时遇到了类似的问题,其他答案都没有帮助。该问题是由为名为 的包构建“轮子”引起的pyzmq,错误消息填满了数百页。

The solution I found was to directly install an older version of that package:

我找到的解决方案是直接安装该软件包的旧版本:

python -m pip install pyzmq==17 --user

After that, the installation of jupytersucceded without errors.

之后,安装jupyter成功,没有错误。

回答by Sergey Solovyev

It helped me to follow instructions in here:

它帮助我按照此处的说明进行操作:

https://packaging.python.org/guides/installing-using-linux-tools/

https://packaging.python.org/guides/installing-using-linux-tools/

Debian/Ubuntu

Debian/Ubuntu

Python 2:

蟒蛇2:

sudo apt install python-pip

Python 3:

蟒蛇3:

sudo apt install python3-venv python3-pip