Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 !?

like image 374
user3313834 Avatar asked Jan 06 '17 11:01

user3313834


People also ask

Where does apt get install Python packages?

If you are a Debian, Ubuntu, or other based distribution and you installed Python through the dpkg packages manager or one of its frontends like apt-get, apt or aptitude, the packages are stored in the /usr/lib/python<version> directory, as shown in the following image where 3.9 must be replaced with your actual Python ...


1 Answers

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
like image 152
Jeremie Guez Avatar answered Sep 20 '22 12:09

Jeremie Guez