ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly

风流意气都作罢 提交于 2021-02-05 10:44:08

问题


I'm trying to install glpk using pip on a virtual enviroment but it keeps giving this error regarding the wheels for pip installing "ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly":

$ pip install glpk
Collecting glpk
  Using cached glpk-0.4.5.tar.gz (152 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: glpk
  Building wheel for glpk (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/yuri/tech/data-science-beeftrader/venv/bin/python /home/yuri/tech/data-science-beeftrader/venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpf31me1rx
       cwd: /tmp/pip-install-w8oh0o0a/glpk
  Complete output (77 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'glpk' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/glpk.c -o build/temp.linux-x86_64-3.8/src/glpk.o
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/2to3.c -o build/temp.linux-x86_64-3.8/src/2to3.o
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/lp.c -o build/temp.linux-x86_64-3.8/src/lp.o
  src/lp.c: In function ‘LPX_init’:
  src/lp.c:135:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    135 |   model[0] = PyString_AsString(model_obj);
        |            ^
  src/lp.c:150:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    150 |    model[i] = PyString_AsString(so);
        |             ^
  src/lp.c: In function ‘LPX_setname’:
  src/lp.c:896:7: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    896 |  name = PyString_AsString(value);
        |       ^
  src/lp.c: In function ‘LPX_getstatus’:
  src/lp.c:952:2: warning: case label value is less than minimum value for type
    952 |  case -1:
        |  ^~~~
  In file included from /usr/include/python3.8/Python.h:64,
                   from src/lp.c:20:
  At top level:
  src/lp.c:1075:14: warning: ‘params_doc’ defined but not used [-Wunused-const-variable=]
   1075 | PyDoc_STRVAR(params_doc,
        |              ^~~~~~~~~~
  /usr/include/python3.8/pymacro.h:70:43: note: in definition of macro ‘PyDoc_VAR’
     70 | #define PyDoc_VAR(name) static const char name[]
        |                                           ^~~~
  src/lp.c:1075:1: note: in expansion of macro ‘PyDoc_STRVAR’
   1075 | PyDoc_STRVAR(params_doc,
        | ^~~~~~~~~~~~
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/barcol.c -o build/temp.linux-x86_64-3.8/src/barcol.o
  In file included from src/barcol.c:20:
  src/barcol.c: In function ‘BarCol_Index’:
  src/2to3.h:18:27: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     18 | #define PyString_AsString PyUnicode_AsUTF8
        |                           ^~~~~~~~~~~~~~~~
  src/barcol.c:212:18: note: in expansion of macro ‘PyString_AsString’
    212 |     char *name = PyString_AsString(obj);
        |                  ^~~~~~~~~~~~~~~~~
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/bar.c -o build/temp.linux-x86_64-3.8/src/bar.o
  src/bar.c: In function ‘Bar_setname’:
  src/bar.c:212:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    212 |   name = PyString_AsString(value);
        |        ^
  In file included from src/bar.c:20:
  src/bar.c: In function ‘Bar_setstatus’:
  src/2to3.h:18:27: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     18 | #define PyString_AsString PyUnicode_AsUTF8
        |                           ^~~~~~~~~~~~~~~~
  src/bar.c:380:16: note: in expansion of macro ‘PyString_AsString’
    380 |   char *sstr = PyString_AsString(value);
        |                ^~~~~~~~~~~~~~~~~
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/obj.c -o build/temp.linux-x86_64-3.8/src/obj.o
  src/obj.c: In function ‘Obj_setname’:
  src/obj.c:378:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
    378 |   name = PyString_AsString(value);
        |        ^
  src/obj.c: In function ‘Obj_getvalue’:
  src/obj.c:410:3: warning: case label value is less than minimum value for type
    410 |   case -1:
        |   ^~~~
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/util.c -o build/temp.linux-x86_64-3.8/src/util.o
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/kkt.c -o build/temp.linux-x86_64-3.8/src/kkt.o
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/tree.c -o build/temp.linux-x86_64-3.8/src/tree.o
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION_NUMBER="0.4.5" -I/home/yuri/tech/data-science-beeftrader/venv/include -I/usr/include/python3.8 -c src/environment.c -o build/temp.linux-x86_64-3.8/src/environment.o
  creating build/lib.linux-x86_64-3.8
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.8/src/glpk.o build/temp.linux-x86_64-3.8/src/2to3.o build/temp.linux-x86_64-3.8/src/lp.o build/temp.linux-x86_64-3.8/src/barcol.o build/temp.linux-x86_64-3.8/src/bar.o build/temp.linux-x86_64-3.8/src/obj.o build/temp.linux-x86_64-3.8/src/util.o build/temp.linux-x86_64-3.8/src/kkt.o build/temp.linux-x86_64-3.8/src/tree.o build/temp.linux-x86_64-3.8/src/environment.o -lglpk -lgmp -o build/lib.linux-x86_64-3.8/glpk.cpython-38-x86_64-linux-gnu.so
  /usr/bin/ld: não foi possível localizar -lgmp
  collect2: error: ld returned 1 exit status
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for glpk
Failed to build glpk
ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly

I have glpk installed:

$ glpsol --version
GLPSOL: GLPK LP/MIP Solver, v4.65

And the troubleshooting of glpk manual give those output

$ find -P /usr -name "*glpk.*" \( -type f -o -type l \) -exec file '{}' \; 2>/dev/null
/usr/local/lib/libglpk.la: libtool library file, ASCII text
/usr/local/lib/libglpk.so: symbolic link to libglpk.so.40.3.0
/usr/local/lib/libglpk.so.40.3.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=28b96044318932503036fbb3a4978777f030ba67, with debug_info, not stripped
/usr/local/lib/libglpk.a: current ar archive
/usr/local/lib/libglpk.so.40: symbolic link to libglpk.so.40.3.0
/usr/local/include/glpk.h: C source, ASCII text

I'm using a virtualenviroment

$ printenv | grep PATH
WINDOWPATH=2
PATH=/home/yuri/tech/data-science-beeftrader/venv/bin:/home/yuri/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

And this is my pip version

$ pip --version
pip version 20.1.1

p.s: I've already tried some of the solutions found online such as --no-binary and --no-use-pep517


回答1:


After triyng some different solutions to my problem, I was able to solve it by installing this three packages:

sudo apt install libglpk-dev python3.8-dev libgmp3-dev

And after that running the same command:

pip install glpk



来源:https://stackoverflow.com/questions/62578264/error-could-not-build-wheels-for-glpk-which-use-pep-517-and-cannot-be-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!