我有一个使用Microsoft 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!
答案 0 :(得分:1)
pywin32
是WinAPI包装程序,因此它是仅Windows的程序包,您不能在Linux上使用它。
Travis CI默认在Linux上运行,但是自2018年10月以来,可以通过在os: windows
文件中添加.travis.yml
来使用Windows。查看Travis blog post。
但是,由于它是“早期访问”功能,因此它仍然会遗漏许多内容,包括Python support。因此,如果您现在需要Python-唯一的方法是手动安装它,例如here
- os: windows
language: sh
python: "3.7"
before_install:
- choco install python3
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
- python -m pip install --upgrade pip wheel