# The Docker image build failed, Numpy required

**URL:** <https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116>\
**Category:** RenkuLab\
**Created:** [20 May 2020 07:22 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116 "2020-05-20T07:22:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjinko](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sjinko](https://renku.discourse.group/u/sjinko)\
**Post date:** [20 May 2020 07:22 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/1 "2020-05-20T07:22:04Z")

</div>

Hi,  
When building the docker image, I get the following error. Basically, it says the “cartopy” package needs “numpy” installed, but it get installed right before.

```
Collecting numpy
Downloading numpy-1.18.4-cp37-cp37m-manylinux1_x86_64.whl (20.2 MB)
Collecting cartopy
Downloading Cartopy-0.18.0.tar.gz (14.4 MB)
ERROR: Command errored out with exit status 1: command: /opt/conda/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tpnw_7es/cartopy/setup.py'"'"'; __file__ ='"'"'/tmp/pip-install-tpnw_7es/cartopy/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-tpnw_7es/cartopy/pip-egg-info
 cwd: /tmp/pip-install-tpnw_7es/cartopy/
Complete output (12 lines):
Traceback (most recent call last):
File "/tmp/pip-install-tpnw_7es/cartopy/setup.py", line 43, in <module>
 import numpy as np
ModuleNotFoundError: No module named 'numpy'
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-tpnw_7es/cartopy/setup.py", line 45, in <module>
 raise ImportError('NumPy 1.10+ is required to install cartopy.')
ImportError: NumPy 1.10+ is required to install cartopy.
 ----------------------------------------
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 conda env update -q -f /tmp/environment.yml && /opt/conda/bin/pip install -r /tmp/requirements.txt && conda clean -y --all && conda env export -n "root"' returned a non-zero code: 1
ERROR: Job failed: exit code 1
```

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [20 May 2020 07:34 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/2 "2020-05-20T07:34:43Z")

</div>

Hi @sjinko - are you installing numpy and cartopy in the same `pip install` statement?

---

<div class="post-metadata">

**Author:** ![sjinko](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sjinko](https://renku.discourse.group/u/sjinko)\
**Post date:** [20 May 2020 10:17 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/3 "2020-05-20T10:17:36Z")

</div>

This happens when I start a new environment on Renkulab, and the packages are getting installed as part of the requirements.txt file. I do not specify installing “cartopy”, so I think it’s a dependency from another package, I can’t figure out which one.

I get to build the Docker image if I remove everything from the requirements.txt file, but then, the create a new environment stalls on  
`Verifying available environments... `  
I also get this notification on top:  
`An error prevented checking integration of the project with the Knowledge Graph. Error: "Error 500"`

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [20 May 2020 10:22 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/4 "2020-05-20T10:22:10Z")

</div>

Yes, apologies for that we are in the middle of an outage - you can follow updates on [renkulab.statuspage.io](http://renkulab.statuspage.io)

As far as your cartopy problem goes - this is due to the fact that cartopy doesn’t specify their _install_ dependencies properly. They require numpy when the package is being installed, meaning that if numpy is installed at the same time as cartopy, _it is not installed yet_ and cartopy’s `setup.py` doesn’t see it. Try adding a line just above that installs just numpy, e.g.

```auto
RUN pip install numpy

```

---

<div class="post-metadata">

**Author:** ![sjinko](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sjinko](https://renku.discourse.group/u/sjinko)\
**Post date:** [20 May 2020 14:29 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/5 "2020-05-20T14:29:30Z")

</div>

I added `RUN pip install numpy` to the _requirements.txt_ file, but I get this:

` ERROR: Invalid requirement: 'RUN pip install numpy' (from line 1 of /tmp/requirements.txt) 43 The command '/bin/sh -c conda env update -q -f /tmp/environment.yml && /opt/conda/bin/pip install -r /tmp/requirements.txt && conda clean -y --all && conda env export -n "root"' returned a non-zero code: 1 47 ERROR: Job failed: exit code 1`

Even if I remove everything from the _requirements.txt_ file, the “start a new interactive environment” gets stuck on: `Loading environment parameters...`

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [20 May 2020 14:31 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/6 "2020-05-20T14:31:08Z")

</div>

Ah sorry, I should have been more clear - you need to add that line to the `Dockerfile` just before the `RUN pip install -r /tmp/requirements.txt` line.

---

<div class="post-metadata">

**Author:** ![sjinko](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sjinko](https://renku.discourse.group/u/sjinko)\
**Post date:** [20 May 2020 14:39 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/7 "2020-05-20T14:39:06Z")

</div>

It does the trick. I get to build the Docker image, but then, it still gets stuck on `Loading environment parameters...`

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [20 May 2020 14:48 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/8 "2020-05-20T14:48:22Z")

</div>

Yes, the outage is still on-going – see [5/19/20 renkulab.io outage](https://renku.discourse.group/t/5-19-20-renkulab-io-outage/124)

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [20 May 2020 15:27 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/9 "2020-05-20T15:27:38Z")

</div>

Hi @sjinko [renkulab.io](http://renkulab.io) is back to (hopefully) normal - let me know if the image build worked as expected!

---

<div class="post-metadata">

**Author:** ![sjinko](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@sjinko](https://renku.discourse.group/u/sjinko)\
**Post date:** [20 May 2020 15:31 UTC](https://renku.discourse.group/t/the-docker-image-build-failed-numpy-required/116/10 "2020-05-20T15:31:59Z")

</div>

Ok, I didn’t get the outage had this effect. Thanks for the help. As usual, @rrrrrok, you save the day!
