opencobra/swiglpk

Can't install swiglpk/cobrapy in Docker image

Closed this issue · 4 comments

This is my docker file which fails when building.

FROM python:3.10 AS base
RUN pip install pipenv
RUN apt-get update && apt-get install -y --no-install-recommends gcc
RUN PIPENV_VENV_IN_PROJECT=1 
RUN pipenv install cobra

Any help would be appreciated. This happens for python images 3.9 and 3.8 as well. FYI, I've also created a similar issue in cobrapy

I get the following error message:

#8 7.649 Collecting swiglpk
#8 7.649   Downloading swiglpk-5.0.0.tar.gz (32 kB)
#8 7.649   Preparing metadata (setup.py): started
#8 7.649   Preparing metadata (setup.py): finished with status 'error'
#8 7.649 
  error: subprocess-exited-with-error
#8 7.649   
#8 7.649   × python setup.py egg_info did not run successfully.
#8 7.649   │ exit code: 1
#8 7.649   ╰─> [13 lines of output]
#8 7.649       Traceback (most recent call last):
#8 7.649         File "<string>", line 2, in <module>
#8 7.649         File "<pip-setuptools-caller>", line 34, in <module>
#8 7.649         File "/tmp/pip-install-f0og7wp6/swiglpk_0fbc9a0e2e46479c86d9d5d73d4c7b75/setup.py", line 52, in <module>
#8 7.649           glpk_header_dirname = find_glpk_header()
#8 7.649         File "/tmp/pip-install-f0og7wp6/swiglpk_0fbc9a0e2e46479c86d9d5d73d4c7b75/setup.py", line 35, in find_glpk_header
#8 7.649           glpsol_dirname = os.path.dirname(subprocess.check_output(['which', 'glpsol']))
#8 7.649         File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output
#8 7.649           return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
#8 7.649         File "/usr/local/lib/python3.10/subprocess.py", line 524, in run
#8 7.649           raise CalledProcessError(retcode, process.args,
#8 7.649       subprocess.CalledProcessError: Command '['which', 'glpsol']' returned non-zero exit status 1.
#8 7.649       Trying to determine glpk.h location
#8 7.649       [end of output]
#8 7.649   
#8 7.649   note: This error originates from a subprocess, and is likely not a problem with pip.
#8 7.649 error: metadata-generation-failed
#8 7.649 
#8 7.649 × Encountered error while generating package metadata.
#8 7.649 ╰─> See above for output.
#8 7.649 
#8 7.649 note: This is an issue with the package mentioned above, not pip.
#8 7.649 hint: See above for details.
#8 7.649 
This is likely caused by a bug in cobra. Report this to its maintainers.
#8 7.691✘ Installation Failed 

Try to install wheel in your first pip call as well. It should be using the precompiled wheels. Also 5.0.0 is an older version, so I am surprised it doesn't try to install the most recent version.

I tested this and it works with installing wheel.

Sorry I never got back.

Actually my issue was the I was using an ARM CPU (apple silicon) but not specifying that I needed an ARM image. I fixed it by adding that to the FROM call.

Thanks for the help

Oh cool, we recently also added support for Linux and Mac native ARM wheels as well.