use apt-get install python packages in .gitlab-ci.yml

17.1k views Asked by At

my gitlab-ci.yml I install python-pandas but I can't use it from python.

$ cat .gitlab-ci.yml
image: python:2

test:
  script:
  - apt-get update -qy
  - apt-get install -y python-pip python-pandas
  - ls /usr/local/lib/python2.7/site-packages
  - python -c 'import pandas'

The runner failed with this message::

 $ python -c 'import pandas'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ImportError: No module named pandas
  ERROR: Build failed: exit code 1

I try to not install pandas with pip as requirement (old pandas lib is enought) And very much would like to understand why python packages are not exposed ? this look like an implicit virtualenv !?

1

There are 1 answers

0
Jeremie Guez On

You should create a virtualvenv in before_script:

before_script:
  - apt-get -qq update && apt-get -qq install -y python
  - apt-get -qq update
  - apt-get -qq install -y python python-virtualenv python-pip
  - virtualenv venv
  - . venv/bin/activate
  - python -V
  - pip install pandas