pandas 在 .gitlab-ci.yml 中使用 apt-get install python 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41504869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
use apt-get install python packages in .gitlab-ci.yml
提问by user3313834
my gitlab-ci.yml
I install python-pandas but I can't use it from python.
我gitlab-ci.yml
安装了 python-pandas,但我不能从 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 !?
我尽量不安装带有 pip 的 pandas 作为要求(旧的 pandas lib 就足够了)并且非常想了解为什么 python 包没有暴露?这看起来像一个隐式的 virtualenv !?
回答by Jeremie Guez
You should create a virtualvenv in before_script
:
您应该在before_script
以下位置创建一个 virtualvenv :
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