setuptools is on v3.3 inside Dockerfile but actually is on v20.7.0 - docker

I'm running the following commands inside Ubuntu 16.04:
git clone git#github.com:liveblog/liveblog.git
cd liveblog
docker build .
This gives me the following output:
[.....]
Downloading/unpacking jmespath>=0.7.1,<1.0.0 (from boto3>=1.1.4,<1.5->Superdesk-Core->-r /tmp/requirements.txt (line 10))
Downloading jmespath-0.9.3-py2.py3-none-any.whl
Downloading/unpacking cryptography>=2.1.4 (from pyOpenSSL->flask-sentinel>=0.0.4,<0.1->Superdesk-Core->-r /tmp/requirements.txt (line 10))
Running setup.py (path:/tmp/pip_build_root/cryptography/setup.py) egg_info for package cryptography
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/cryptography/setup.py", line 28, in <module>
"cryptography requires setuptools 18.5 or newer, please upgrade to a "
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/cryptography/setup.py", line 28, in <module>
"cryptography requires setuptools 18.5 or newer, please upgrade to a "
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c cd /tmp && pip3 install -U -r /tmp/requirements.txt' returned a non-zero code: 1
Checking the installed version of setuptools via pip3 list and pip list returns:
[...]
setuptools (20.7.0)
[...]
I added the following line into the Dockerfile right before RUN cd /tmp && pip3 install -U -r /tmp/requirements.txt:
RUN pip3 list
and then when I run docker build . again I get the following output:
Step 20/27 : RUN pip3 list
---> Running in 391e5e5e490b
chardet (2.2.1)
colorama (0.2.5)
html5lib (0.999)
lxml (3.3.3)
pip (1.5.4)
requests (2.2.1)
setuptools (3.3)
six (1.5.2)
urllib3 (1.7.1)
Why is setuptools now on v3.3 and how am I able to save this behavior?

I am assuming that you must have been checking setup tools on your host-machine, that says (20.7.0) , however it should have been upgraded inside Docker-Image. (Inside your docker images as you said it is : 3.3.
Try replacing your instructions with this one or may be anything that is more suitable.
#> RUN cd /tmp && pip3 install -U setuptools && pip3 list && pip3 install -U -r /tmp/requirements.txt
This will resolve the current issue that is related to setuptools version.

Related

Docker: unable to acces other files in directory

I'm new to docker and I'm trying to create a docker image in which a python 2.7 script runs. This file imports functions and classes from other files in the same directory. Building the docker image already works, but running it gives an error that the imported files in the python 2.7 script don't exist.
This is the dockerfile I'm using
FROM python:2.7
WORKDIR C:\something\something\print
RUN apt-get update
RUN apt-get install python-cairo
RUN apt-get install python-gi
RUN apt-get install python-gi-cairo
RUN apt-get install -y gir1.2-gtk-3.0
RUN apt-get install -y mapnik-utils
RUN pip install bs4
RUN pip install image
RUN pip install mapnik
RUN pip install numpy
RUN pip install psycopg2
COPY test_server.py ./
CMD [ "python", "./test_server.py"]
And this is the error I receive after I do "docker run"
Traceback (most recent call last):
File "./test_server.py", line 13, in <module>
from utils import client, reprojector, formats
ImportError: No module named utils
The module named utils is a folder in the WORKDIR I specified in the dockerfile, but I don't understand why it can't be accessed. What am I doing wrong here?

pip install: metadata-generation-failed in docker

This is my Dockerfile:
FROM alpine:3.14
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add python3-dev # for python3.x installs
RUN apk add musl-dev
RUN apk add gcc
RUN mkdir -p /usr/src/tap-stashstock
RUN mkdir -p /usr/singer
WORKDIR /usr/src/tap-stashstock
ADD . /usr/src/tap-stashstock
ADD singer /usr/singer
RUN pip3 install --upgrade .
This works and then I run docker run -it stashstock-to-bigquery pip3 install target-bigquery which results in this error
Collecting grpcio<2.0dev,>=1.38.1
Downloading grpcio-1.44.0.tar.gz (21.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.4/21.4 MB 3.9 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 256, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 203, in check_linker_need_libatomic
cpp_test = subprocess.Popen([cxx, '-x', 'c++', '-std=c++11', '-'],
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
What am I missing from my Dockerfile?
This error may for not having a C/C++ compiler.
Try install gcc and build-essensial before pip installation.
Please follow the steps given in
https://github.com/grpc/issues/24556

ModuleNotFoundError: No module named 'OpenSSL' while creating Dockerfile

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)

docker build failed at 'Downloading mariadb'

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

Unable to deploy docker solution with conda-forge

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

Resources