Dockerfile
FROM alpine:3.9
RUN apk add --no-cache python3 && \
python3 -m ensurepip && \
pip3 install --upgrade pip setuptools
RUN pip3 install --upgrade pip
RUN pip3 install numpy==1.16.1 pandas==0.23.4
Problem description
I get the following error when I try build the image
~/work/algorithms(master*) » docker build . -t algo-old [py3ds]kamil@beast
Sending build context to Docker daemon 83.6MB
Step 1/4 : FROM alpine:3.9
---> 055936d39205
Step 2/4 : RUN apk add --no-cache python3 && python3 -m ensurepip && pip3 install --upgrade pip setuptools
---> Running in 7e9b12fa6c77
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/11) Installing libbz2 (1.0.6-r7)
(2/11) Installing expat (2.2.8-r0)
(3/11) Installing libffi (3.2.1-r6)
(4/11) Installing gdbm (1.13-r1)
(5/11) Installing xz-libs (5.2.4-r0)
(6/11) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(7/11) Installing ncurses-terminfo (6.1_p20190105-r0)
(8/11) Installing ncurses-libs (6.1_p20190105-r0)
(9/11) Installing readline (7.0.003-r1)
(10/11) Installing sqlite-libs (3.28.0-r1)
(11/11) Installing python3 (3.6.9-r2)
Executing busybox-1.29.3-r10.trigger
OK: 68 MiB in 25 packages
Looking in links: /tmp/tmpu5zsnjnn
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (40.6.2)
Requirement already satisfied: pip in /usr/lib/python3.6/site-packages (18.1)
Collecting pip
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/9e/d5/444a443d890f09fc1ca1a2c3c9fc7e84cb148177b05ac94fe5084e3d9abb/setuptools-42.0.1-py2.py3-none-any.whl (582kB)
Installing collected packages: pip, setuptools
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Found existing installation: setuptools 40.6.2
Uninstalling setuptools-40.6.2:
Successfully uninstalled setuptools-40.6.2
Successfully installed pip-19.3.1 setuptools-42.0.1
Removing intermediate container 7e9b12fa6c77
---> e6282c1ebea1
Step 3/4 : RUN pip3 install --upgrade pip
---> Running in 311cd9140e02
Requirement already up-to-date: pip in /usr/lib/python3.6/site-packages (19.3.1)
Removing intermediate container 311cd9140e02
---> 7af0fdc6e218
Step 4/4 : RUN pip3 install numpy==1.16.1 pandas==0.23.4
---> Running in 6fe4f2f0f09f
Collecting numpy==1.16.1
Downloading https://files.pythonhosted.org/packages/2b/26/07472b0de91851b6656cbc86e2f0d5d3a3128e7580f23295ef58b6862d6c/numpy-1.16.1.zip (5.1MB)
Collecting pandas==0.23.4
Downloading https://files.pythonhosted.org/packages/e9/ad/5e92ba493eff96055a23b0a1323a9a803af71ec859ae3243ced86fcbd0a4/pandas-0.23.4.tar.gz (10.5MB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6_f3wxk2/pandas/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6_f3wxk2/pandas/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-install-6_f3wxk2/pandas/pip-egg-info
cwd: /tmp/pip-install-6_f3wxk2/pandas/
Complete output (61 lines):
WARNING: The wheel package is not available.
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-1tx04x9_/numpy/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-1tx04x9_/numpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ooxld4dn
cwd: /tmp/pip-wheel-1tx04x9_/numpy/
Complete output (7 lines):
Running from numpy source directory.
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for numpy
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-1tx04x9_/numpy/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-1tx04x9_/numpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
cwd: /tmp/pip-wheel-1tx04x9_/numpy
Complete output (10 lines):
Running from numpy source directory.
`setup.py clean` is not supported, use one of the following instead:
- `git clean -xdf` (cleans all files)
- `git clean -Xdf` (cleans all versioned files, doesn't touch
files that aren't checked into the git repo)
Add `--force` to your command to use it anyway if you must (unsupported).
----------------------------------------
ERROR: Failed cleaning build dir for numpy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/setuptools/installer.py", line 119, in fetch_build_egg
subprocess.check_call(cmd)
File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3.6', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpm2wxn48a', '--quiet', 'numpy>=1.9.0']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-6_f3wxk2/pandas/setup.py", line 749, in <module>
**setuptools_kwargs)
File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/lib/python3.6/site-packages/setuptools/dist.py", line 721, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1065, in best_match
return self.obtain(req, installer)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1077, in obtain
return installer(requirement)
File "/usr/lib/python3.6/site-packages/setuptools/dist.py", line 777, in fetch_build_egg
return fetch_build_egg(self, req)
File "/usr/lib/python3.6/site-packages/setuptools/installer.py", line 121, in fetch_build_egg
raise DistutilsError(str(e))
distutils.errors.DistutilsError: Command '['/usr/bin/python3.6', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpm2wxn48a', '--quiet', 'numpy>=1.9.0']' returned non-zero exit status 1.
----------------------------------------
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 numpy==1.16.1 pandas==0.23.4' returned a non-zero code: 1
Expected Output
no errors :)
Output of pd.show_versions()
not applicable
Comment From: jbrockmendel
can you try running pip3 install wheel
first
Comment From: int8
Hi It did help,
but the core of the issue was setuptools version. in my original Dockerfile (a bit larger than the one provided here), I also use pip3 install setuptools
without version specified - apparently it changed recently from 41.2.0
to 42.*
and that caused my problems
fixing pip / setuptools version helped
RUN pip3 install pip==19.3.1 setuptools==41.2.0
Comment From: gourab337
Sometimes the pandas issue occur in Alpine occur due to g++ not being present.
It can be resolved by adding this in your Dockerfile before you run your build command:
RUN apk add make automake gcc g++ subversion python3-dev