Reputation: 716
#!/usr/bin/env python
from time import sleep
import datetime
import os
import shutil
import cv2
import io
import numpy as np
import glob
from threading import Thread
import urllib2
import requests
import json
import boto3
import datetime
I am not able to run my script on docker as I am not able to run modules like cv2
,numpy
, requests
and boto3
. It works perfectly when I run it on terminal but when I run it as docker image it is showing error that no modules named ... How can i make it run on my docker?
Dockerfile:
FROM resin/raspberry-pi-python:latest
RUN mkdir /myscript
WORKDIR /myscript
COPY capturing.py .
CMD ["/myscript/capturing.py", "-flag"]
Upvotes: 2
Views: 6493
Reputation: 2329
You can run your container:
docker run -it <image_name>
and execute the following command in python console that will install specified packages in your container:
import os
os.system("pip install --upgrade pip")
os.system("pip install numpy requests boto3 opencv-python")
You will see:
Collecting numpy
Downloading numpy-1.13.3-cp36-cp36m-manylinux1_x86_64.whl (17.0MB)
100% |████████████████████████████████| 17.0MB 124kB/s
Collecting requests
Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
100% |████████████████████████████████| 92kB 4.8MB/s
Collecting boto3
Downloading boto3-1.4.7-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 3.4MB/s
Collecting opencv-python
Downloading opencv_python-3.3.0.10-cp36-cp36m-manylinux1_x86_64.whl (15.4MB)
100% |████████████████████████████████| 15.5MB 126kB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading certifi-2017.11.5-py2.py3-none-any.whl (330kB)
100% |████████████████████████████████| 337kB 2.9MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 4.4MB/s
Collecting idna<2.7,>=2.5 (from requests)
Downloading idna-2.6-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 6.0MB/s
Collecting urllib3<1.23,>=1.21.1 (from requests)
Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
100% |████████████████████████████████| 133kB 3.4MB/s
Collecting jmespath<1.0.0,>=0.7.1 (from boto3)
Downloading jmespath-0.9.3-py2.py3-none-any.whl
Collecting s3transfer<0.2.0,>=0.1.10 (from boto3)
Downloading s3transfer-0.1.11-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 6.4MB/s
Collecting botocore<1.8.0,>=1.7.0 (from boto3)
Downloading botocore-1.7.46-py2.py3-none-any.whl (3.7MB)
100% |████████████████████████████████| 3.7MB 535kB/s
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.8.0,>=1.7.0->boto3)
Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
100% |████████████████████████████████| 194kB 3.1MB/s
Collecting docutils>=0.10 (from botocore<1.8.0,>=1.7.0->boto3)
Downloading docutils-0.14-py3-none-any.whl (543kB)
100% |████████████████████████████████| 552kB 2.2MB/s
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.8.0,>=1.7.0->boto3)
Downloading six-1.11.0-py2.py3-none-any.whl
Installing collected packages: numpy, certifi, chardet, idna, urllib3, requests, jmespath, six, python-dateutil, docutils, botocore, s3transfer, boto3, opencv-python
Successfully installed boto3-1.4.7 botocore-1.7.46 certifi-2017.11.5 chardet-3.0.4 docutils-0.14 idna-2.6 jmespath-0.9.3 numpy-1.13.3 opencv-python-3.3.0.10 python-dateutil-2.6.1 requests-2.18.4 s3transfer-0.1.11 six-1.11.0 urllib3-1.22
So all is ok. I tested it in container built using FROM python:latest
Dockerfile.
Upvotes: 5