为什么Travis CI无法构建Python项目?

为什么Travis CI无法构建Python项目?,python,python-3.x,pip,continuous-integration,travis-ci,Python,Python 3.x,Pip,Continuous Integration,Travis Ci,我有一个使用微软API(Pywin32)的简单Python脚本。我能够在本地机器上成功运行该项目,但在Travis中,它抛出了一个错误- 100% |████████████████████████████████| 51kB 17.9MB/s Collecting pylint==2.2.2 (from -r requirements.txt (line 15)) Downloading https://files.pythonhosted.org/packages/a5/06/

我有一个使用微软API(Pywin32)的简单Python脚本。我能够在本地机器上成功运行该项目,但在Travis中,它抛出了一个错误-

    100% |████████████████████████████████| 51kB 17.9MB/s 
Collecting pylint==2.2.2 (from -r requirements.txt (line 15))
  Downloading https://files.pythonhosted.org/packages/a5/06/ecef826f319055e6b231716730d7f9047dd7524ffda224b521d989f085b6/pylint-2.2.2-py3-none-any.whl (750kB)
    100% |████████████████████████████████| 757kB 18.9MB/s 
Collecting pywin32==224 (from -r requirements.txt (line 16))
  Could not find a version that satisfies the requirement pywin32==224 (from -r requirements.txt (line 16)) (from versions: )
No matching distribution found for pywin32==224 (from -r requirements.txt (line 16))
The command "pip install -r requirements.txt" failed and exited with 1 during .
Your build has been stopped.
在我的本地系统中,Python版本是
3.6.6
,pip是
18.1
。但如果您注意到Travis中,pip版本是
10.0.1
。这可能是问题所在吗

我的travis.yml文件包含-

language: python
python:
  - "3.6.6"
pip:
  - "18.1"
install:
  - pip install -r requirements.txt
script:
  - python main.py
Python包pywin32==224已经存在,并且可以在我的本地机器上下载,所以我猜错误并不是来自他们

谢谢你的帮助

编辑-

尝试安装Python后,出现以下错误:

0.01s$ source ~/virtualenv/python3.6/bin/activate
$ python --version
Python 3.6.3
$ pip --version
pip 9.0.1 from /home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages (python 3.6)
0.08s$ choco install python3
choco: command not found
The command "choco install python3" failed and exited with 127 during .
Your build has been stopped.
编辑2-

新的.travis.yml:

language: python
python:
  - "3.6"
os: windows
before_install:
        - choco install python3
        - export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
        - python -m pip install --upgrade pip wheel
install:
  - pip install -r requirements.txt
script:
  - python main.py 
输出-

Worker information

The language 'python' is currently unsupported on the Windows Build Environment.
Let us know if you'd like to see it: https://travis-ci.community/c/environments/windows. Thanks for understanding!

pywin32
是WinAPI包装,所以它是仅限Windows的软件包,您不能在Linux上使用它

Travis CI默认在Linux上运行,但自2018年10月起,可以通过在
.Travis.yml
文件中添加
os:Windows
来使用Windows。看看这个

然而,由于它的“早期访问”功能,它仍然错过了很多东西,包括。因此,如果您现在需要Python,唯一的方法就是手动安装,例如

使用Python 3.8更新了示例(2020年4月),该示例现在似乎是默认的:

- os: windows
  language: sh
  python: "3.8"
  before_install:
        - choco install python3
        - export PATH="/c/Python38:/c/Python38/Scripts:$PATH"
        - python -m pip install --upgrade pip wheel

我相信,默认情况下Travis运行Linux,因此那里没有WinAPI。您是否尝试在.travis.yml中添加
os:windows
?请看是的,尝试过,但不幸的是操作系统:windows不支持Python。谢谢。我来试试。更新了问题。更新后的输出看起来仍然像Linux输出。在任何情况下,您都必须有
os:windows
。不,没有更改。似乎根本不支持Python。更新(编辑2)@BoudhayanDev请仔细阅读最后一个链接的内容。已经有项目成功地使用了它。您不应该使用
language:python
,因为它不受支持,您必须自己安装所有需要的东西