Reputation: 123
I'm trying to work on the code in this GitHub repository to process datasets from News articles. I'm following their docker installation steps and the first two execute without any errors.
However, with the third one, docker run --rm -it -v ${PWD}:/usr/src/newsqa --name newsqa maluuba/newsqa python maluuba/newsqa/data_generator.py
,
I get the following error:
Traceback (most recent call last):
File "maluuba/newsqa/data_generator.py", line 8, in <module>
from simplify import simplify
File "/usr/src/newsqa/maluuba/newsqa/simplify.py", line 5, in <module>
import pandas as pd
ImportError: No module named pandas
This is part of what the Dockerfile has :
FROM continuumio/miniconda:4.5.11
# Setup the Python environment.
RUN conda create --yes --name newsqa python=2.7 "pandas>=0.19.2" cython
RUN echo "conda activate newsqa" >> ~/.bashrc
WORKDIR /usr/src/newsqa
COPY requirements.txt ./
RUN /bin/bash --login -c "conda list && yes | pip install --requirement requirements.txt"
I have never worked with Docker before so I'm assuming this should be installing pandas but I have no clue what else to do!
I found this issue similar to mine but I'm not really understanding anything clearly. Should I "get into" the docker and then do a pip install manually? I'm unable to find the container ID with this command docker ps -aqf "name=containername"
. It returns nothing.
I have been stuck on this for days now and would really appreciate any help I can get.
Upvotes: 2
Views: 2767
Reputation: 42040
The issue is that if you run it like this:
docker run --rm -it -v ${PWD}:/usr/src/newsqa --name newsqa maluuba/newsqa python maluuba/newsqa/data_generator.py
bash
never enters the picture, therefore the correct version of the Python environment is never chosen (in fact, only Python will be running, no shell at all).
An easy fix is to invoke it like this:
docker run --rm -it -v ${PWD}:/usr/src/newsqa --name newsqa newsqa /bin/bash --login -c "python maluuba/newsqa/data_generator.py"
which will execute it via bash with the --login
option will also source the necessary environment.
Upvotes: 1