I'm trying to use gitlab CI for the first time. I just want to test (not to deploy) a Python program on it. I don't know why but it failed on pip, which is not found...
Here is the error message of gitlab :
Skipping Git submodules setup
$ pip install -r requirements.txt
/bin/bash: line 71: pip: command not found
ERROR: Job failed: exit code 1
And here my .gitlab-ci.yaml:
stages:
- build
- test
myJob:
stage: build
image: python:3.6
script:
- apt-get update -q -y
- apt-get install -y python-pip
- python -V
- echo "hello world"
- pip install -r requirements.txt
myJob2:
stage: test
script:
- python test.py
Neither the hello world nor the Python version is printed. So I probably made a basic mistake, but which one?
Solve the Warning: There was an error checking the latest version of pip error. The best way to solve this error is to install or update the pip module to the latest version. Before installing the pip module make sure that all the dependencies for this module should be installed.
Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!
Different jobs in your pipeline are run in different containers. To be precise, they run in the container that you specify as image
. The job myJob
runs inside a python:3.6
container, so you have the pip
command and everything works fine.
For your second job (myJob2
), you did not specify any image, so the default image will be used, which will likely not be a python image.
Even if your second job was running inside a python
container, it would still fail because of missing dependencies. You are installing the dependencies in the first job, but you did not specify any artifacts that should be passed to the next job. For more information on passing these artifacts check the Gitlab CI reference.
The following .gitlab-ci.yml
should work:
stages:
- build
- test
myJob:
stage: build
image: python:3.6
script:
- apt-get update -q -y
- apt-get install -y python-pip
- python -V
- echo "hello world"
- pip install -r requirements.txt
artifacts:
untracked: true
myJob2:
stage: test
image: python:3.6
script:
- python test.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With