简体   繁体   中英

Why does Travis CI fails to build Python project?

I have a simple Python script that uses Microsoft's API ( Pywin32 ). I am able to run the project successfully in my local machine but in Travis , it throws an error -

    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.

In my local system Python version is 3.6.6 and pip is 18.1 . But if you notice in Travis , pip version is 10.0.1 . Could this be the issue ?

My travis.yml file contains -

language: python
python:
  - "3.6.6"
pip:
  - "18.1"
install:
  - pip install -r requirements.txt
script:
  - python main.py

The Python package pywin32==224 exists and can be downloaded on my local machine so I guess the error is not from their side.

Thanks for the help.

EDIT -

After trying to install Python , the following error resulted :

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.

EDIT 2 -

The new .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 

The output -

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 is WinAPI wrapper, so it's Windows-only package, you cannot use it on Linux.

Travis CI runs on Linux by default, but since October 2018 there is possibility to use Windows by adding os: windows in your .travis.yml file. Check out Travis blog post on this.

However since it's "early access" feature it still misses a lot of stuff including Python support . So if you need Python now - the only way is to install it manually, ie like here

Updated example (April 2020) with Python 3.8 which seems to be default now:

- 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM