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


当前回答

必须安装车轮组件。一切都是最新的,但仍然存在错误。

pip install wheel

then

python setup.py bdist_wheel 

工作没有问题。

其他回答

在我的情况下,venv创建的wheel/pip/setuptools版本太旧了。这是有效的:

venv/bin/pip  install --upgrade pip wheel setuptools

它帮助我遵循这里的指示:

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

Debian/Ubuntu

Python 2:

sudo apt install python-pip

Python 3:

sudo apt install python3-venv python3-pip

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

pip uninstall wheel
pip install wheel

奇怪的

我在Ubuntu中安装了python3dev,并在setup.py中添加了setup_requires=[“wheel”]

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

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