我的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

但当我在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

我得到:

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'

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


当前回答

正如@Philippe Remy所提到的,应从setuptools导入

from setuptools import setup

参考:官方文件https://setuptools.pypa.io/en/latest/index.html

其他回答

使用Ubuntu 18.04,这个问题可以通过安装python3 wheel包来解决。

通常,这是作为任何Python包的依赖项安装的。但尤其是在构建您经常使用的容器映像时,不建议安装,因此它经常丢失,必须首先手动安装。

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

pip uninstall wheel
pip install wheel

奇怪的

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

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

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

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

正如@Philippe Remy所提到的,应从setuptools导入

from setuptools import setup

参考:官方文件https://setuptools.pypa.io/en/latest/index.html

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