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

其他回答

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

from setuptools import setup

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

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

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

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

如果您使用的是setup.cfg文件,请在install_require部分之前添加:

setup_requires =
    wheel

setup.cfg项目示例:

# setup.py
from setuptools import setup

setup()
# setup.cfg
[metadata]
name = name
version = 0.0.1
description = desc
long_description = file: README.md
long_description_content_type = text/markdown
url = url
author = author
classifiers =
    Programming Language :: Python
    Programming Language :: Python :: 3

[options]
include_package_data = true
packages = find:
setup_requires =
    wheel
install_requires =
    packages
    packages
    packages

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

pip install wheel

then

python setup.py bdist_wheel 

工作没有问题。