Executing 'docker build -t $name .' failed at following issue. It shows 'mariadb_config not found', but i already installed mariadb on this suse15 linux server.
Collecting mariadb==1.0.4
Downloading mariadb-1.0.4.tar.gz (66 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-hicsuruq
cwd: /tmp/pip-install-lxx0giq5/mariadb/
Complete output (17 lines):
/bin/sh: 1: mariadb_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lxx0giq5/mariadb/setup.py", line 26, in <module>
cfg = get_config(options)
File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 59, in get_config
cc_version = mariadb_config(config_prg, "cc_version")
File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 29, in mariadb_config
"mariadb_config not found.\n\nPlease make sure, that MariaDB Connector/C is installed on your system.\n"
OSError: mariadb_config not found.
Please make sure, that MariaDB Connector/C is installed on your system.
Either set the environment variable MARIADB_CONFIG or edit the configuration
file 'site.cfg' and set the 'mariadb_config option, which should point
to the mariadb_config utility.
The MariaDB Download website at <https://downloads.mariadb.com/Connectors/c/>
provides latest stable releease of Connector/C.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1
And related Dockerfile content is as follows.
FROM python:3.6.5
WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "/slic-scripts/run_cmd.sh"]
As #Jonathan Jacobson wrote, you need to have the MariaDB Connector installed in your Docker image before proceeding with pip install.
Since python:3.6.5 is based on debian stretch, the connector offered there is 2.3.2 which is not supported by the mariadb module (as stated in the prerequisites). To fix this, you might want to switch to a different image (e.g. 3.6-buster).
Here's a working test:
FROM python:3.6-buster
RUN apt-get update \
&& apt-get -yy install libmariadb-dev
WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "/slic-scripts/run_cmd.sh"]
You need to install MariaDB Connector/C inside the Dockerfile, before running pip3 install. It doesn't help that you installed it on your host.
Install MariaDB Connector/C using the below command, which is a dependency.
sudo apt-get install libmariadb3 libmariadb-dev
RUN pip3 install -r requirements.txt
Related
I am quite new to docker. My problem in short is to create a docker file that contains python with sklearn and pandas which can be used on aws sagemaker.
My current docker file looks like the following:
FROM jupyter/scipy-notebook
RUN pip3 install sagemaker-training
COPY train.py /opt/ml/code/train.py
ENV SAGEMAKER_PROGRAM train.py
However when i try to create this image I get an error at line pip3 install sagemaker-training. The error is the following:
error: command 'gcc' failed: No such file or directory
ERROR: Command errored out with exit status 1: /opt/conda/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fj0cb373/sagemaker-training_66ca9935ed134c95ac11a32e118e4568/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fj0cb373/sagemaker-training_66ca9935ed134c95ac11a32e118e4568/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-o5rzjscd/install-record.txt --single-version-externally-managed --compile --install-headers /opt/conda/include/python3.9/sagemaker-training Check the logs for full command output.
The command '/bin/bash -o pipefail -c pip3 install sagemaker-training' returned a non-zero code: 1
If there is a more suitable base image can someone point that out to me? I am generally trying to follow this page https://github.com/aws/sagemaker-training-toolkit.
Note: I realise I can use some sagemaker pre-built containers without using my own docker file. However I am trying to do this for my own learning so I know what to do for projects that can't utilise them.
I adjusted your Dockerfile and it builds successfully for me.
FROM jupyter/scipy-notebook
ARG defaultuser=jovyan
USER root
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
USER $defaultuser
RUN pip3 install sagemaker-training
COPY train.py /opt/ml/code/train.py
ENV SAGEMAKER_PROGRAM train.py
(I had to adjust for the fact that the default user from the base container isn't root, when installing GCC)
I create the docker file for my flask app that is running on port 3000.
That is my docker file
<-----------------Dockerfile---------------------->
FROM python:3
WORKDIR /app
EXPOSE 3000
COPY ./requirements.txt ./
RUN pip install -r requirements.txt
COPY ./ ./
CMD ["python","run.py"]
<--------------------- requirements.txt--------------------------------->
I generated it by using "pipreqs"
pyOpenSSL==20.0.1
Flask_Login==0.5.0
SQLAlchemy==1.3.12
Flask_WTF==0.15.1
WTForms==2.3.3
Flask_SQLAlchemy==2.5.1
Flask_Bcrypt==0.7.1
Flask==2.0.1
Pillow==8.3.2
secrets==1.0.2
<------------------------------Error that I encounter------------------------------>
E
RROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py'"'"'; __file__='"'"'/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ub_x6ltz
cwd: /tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/
Complete output (12 lines):
Traceback (most recent call last):
File "/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py", line 10, in <module>
import OpenSSL
ModuleNotFoundError: No module named 'OpenSSL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-aesbht7l/secrets_faf11378a9b945deb5114ab973cefa73/setup.py", line 12, in <module>
raise ImportError('Installing this module requires OpenSSL python bindings')
ImportError: Installing this module requires OpenSSL python bindings
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/93/c4/166925e31bc06bfe49deb4dc3922584790a33b897509bac388acdc074a60/secrets-1.0.2.tar.gz#sha256=37075ab08607092e76da2b86e94dd38a0216ec80088a0a3f9220077750aeddf9 (from https://pypi.org/simple/secrets/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement secrets==1.0.2 (from versions: 1.0.2)
ERROR: No matching distribution found for secrets==1.0.2
I even added pyOpenSSL in requirements.txt but the error keeps saying like that. Did I choose the wrong python image? Is it related to that?
Consider installing additional packages:
FROM python:3
WORKDIR /app
EXPOSE 3000
RUN apt-get update
RUN apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
COPY ./requirements.txt ./
RUN pip install -r requirements.txt
COPY ./ ./
CMD ["python","run.py"]
(got the answer from here: I can't install python-ldap)
I'm trying to build a Docker image on Ubuntu 20.04 WSL for Windows 10 and keep running into the following error when Docker gets to the step to run pip3 install:
/bin/sh: 1: pip3: not found
The command '/bin/sh -c pip3 install -r /tmp/requirements.txt' returned a non-zero code: 127
The Dockerfile is:
FROM ubuntu:20.04
COPY bots/art_print.py /bots/
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt
WORKDIR /bots
CMD ["python3", "art-print-bot"]
I've uninstalled and reinstalled pip3 and verified that it is there with $ which pip3
/usr/bin/pip3
Any ideas as to why the Docker build is not recognizing pip3?
Looks like you may have an issue with your PATH environment variable. Try changing the pip RUN line to:
RUN python3 -m pip install -r /tmp/requirements.txt
This is my first Dockerfile and this is what I have so far.
FROM python:3.6-stretch
# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential
# check our python environment
RUN python3 --version
RUN pip3 --version
# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring
# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy all the files from the project’s root to the working directory
COPY src/ /src/
RUN ls -la /src/*
# Running Python Application
CMD ["python3", "/src/main.py"]
But when I am trying to run the docker image the files inside the data folder cannot be found.
Here is a picture of the my project structure.
Changed it to what was suggested and still getting an error.
FROM python:3.6-stretch
# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential
# check our python environment
RUN python3 --version
RUN pip3 --version
# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring
# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy all the files from the project’s root to the working directory
COPY src/ /src/
COPY data /data/
RUN ls -la /src/*
# Running Python Application
CMD ["python3", "/src/main.py"]
This is the error message.
docker run toxic-content-monitoring:0.1
wiki.en.vec: 6.60GB [10:05, 10.9MB/s]
0%| | 0/2519371 [00:00<?, ?it/s]Skipping token 2519370 with 1-dimensional vector ['300']; likely a header
100%|██████████| 2519371/2519371 [08:36<00:00, 4878.67it/s]
Traceback (most recent call last):
File "/src/main.py", line 11, in <module>
from preprocessor import normalize_comment, clean_text
File "/src/preprocessor.py", line 42, in <module>
word_file = open(link, "r")
FileNotFoundError: [Errno 2] No such file or directory: 'data/identity_hateWordFile.txt'
I believe your Dockerfile is missing COPY data/ /data/ command in it. You are only doing a copy of src folder and not data. Please include COPY data /data/ right after COPY src/ /src/ line in your Dockerfile and give it a try.
I am deploying a docker solution for my application. In my docker file I used multiple conda-forge to build some containers. It worked very well for some of the containers, and give an error for the other and I am sure it is not about the package, because for the same package sometimes it work and others no.
I have tried to use pip instead of conda, but that lead to other errors since I am using conda originally for all of my configuration. Also, I read that RUN conda update --all will solve it, and for pip setup RUN pip install --upgrade setuptools
This is part of my docker file :
FROM dockerreg.cyanoptics.com/cyan/openjdk-java8:1.0.0
RUN conda update --all
RUN conda install -c conda-forge happybase=1.1.0 --yes
RUN conda install -c conda-forge requests-kerberos
RUN pip install --upgrade setuptools
RUN pip install --upgrade pip
RUN pip install kafka-python
RUN pip install requests-negotiate
The expected result is to build all containers successfully, but I am getting the following:
---> Using cache
---> 82f4cd49037d
Step 14 : RUN conda install -c conda-forge happybase=1.1.0 --yes
---> Using cache
---> c035b960aa3b
Step 15 : RUN conda install -c conda-forge requests-kerberos
---> Running in 54d869afcd00
Traceback (most recent call last):
File "/opt/conda/bin/conda", line 7, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
The command '/bin/sh -c conda install -c conda-forge requests-
kerberos' returned a non-zero code: 1
make: *** [dockerimage] Error 1
Try combining the two conda install commands into a single command: RUN conda install -c conda-forge happybase=1.1.0 requests-kerberos --yes.
I ran into a similar issue with the install commands split up; it turns out the issue was that the first caused the python version to be upgraded, which in turn was incompatible with the conda install command - causing the error you're seeing.
Another workaround I found was to add python 3.6.8 as another install arg. One of the packages I was installing must have had a python 3.7 dependency, forcing it to upgrade python, and breaking conda install.
Actually the error indicates the wrong path for conda /bin/sh
Therefore adding the proper path to the Dockerfile will solve the issue as following :
ENV PATH /opt/conda/envs/env/bin:$PATH
A good reference to related topic is here, where it suggests to create a new virtual environment within the dockerfile:
https://medium.com/#chadlagore/conda-environments-with-docker-82cdc9d25754