【发布时间】:2020-10-16 01:59:14
【问题描述】:
我正在尝试在虚拟环境中使用 pip 安装 glpk,但它不断给出有关 pip 安装轮子的此错误“错误:无法为使用 PEP 517 且无法直接安装的 glpk 构建轮子”:
$ 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
我已经安装了 glpk:
$ glpsol --version
GLPSOL: GLPK LP/MIP Solver, v4.65
glpk手册的故障排除给出了这些输出
$ 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
我正在使用虚拟环境
$ 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
这是我的 pip 版本
$ pip --version
pip version 20.1.1
p.s:我已经尝试了一些网上找到的解决方案,例如--no-binary和--no-use-pep517
【问题讨论】:
-
这应该去上游的bugtracker,而不是在这里。如果您想在这里问这个问题,您首先必须提取 minimal reproducible example 并将其作为您问题的一部分提供。