python - 在 Windows10 上安装 pyglpk 包
问题描述
我对安装软件包等的技术细节知之甚少,所以这可能是一个愚蠢的问题。我只是先下载了 GLPK 并将其添加到路径中,然后尝试通过 pyglpk 安装pip install glpk
,这会给出以下错误消息:
Collecting glpk
Using cached https://files.pythonhosted.org/packages/74/e0/8676d8d5404a8f9aee298985d21aae67b776476b01583ff1a3e0030e2f51/glpk-0.4.5.tar.gz
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: Complete output from command 'C:\Users\User\Anaconda3\python.exe' 'C:\Users\User\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\User\AppData\Local\Temp\tmpzvxrzwqg':
ERROR: running bdist_wheel
running build
running build_ext
building 'glpk' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DVERSION_NUMBER="0.4.5" -IC:\Users\User\Anaconda3\include -IC:\Users\User\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcsrc\glpk.c /Fobuild\temp.win-amd64-3.7\Release\src\glpk.obj
glpk.c
c:\users\user\appdata\local\temp\pip-install-m71t9t2y\glpk\src\lp.h(24): fatal error C1083: Cannot open include file: 'glpk.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for glpk
Running setup.py clean for glpk
Failed to build glpk
ERROR: Could not build wheels for glpk which use PEP 517 and cannot be installed directly
我尝试在网上搜索不同的安装教程或问题,但大多数是针对 Linux/MacOS 的,而不是针对 Windows 的。我能做些什么呢?
解决方案
我找到了一个解决方案,可以在不使用 PIP 的情况下在 python 中运行 glpk。我遇到了同样的问题,无法用 PIP 解决。
首先是下载 GLPK 求解器: https : //sourceforge.net/projects/winglpk/ GLPK 基于 C。您必须检查名为 glpsol.exe 的文件在哪里并将该目录添加到路径中。 看这张图片中标注的 txt
之后,您可以运行您的 pyomo 模型并选择 GLPK 作为您的求解器。
推荐阅读
- python - 单击感兴趣的 Y 轴值以调整彩条
- android - 试图了解发布调试和正式发布应用程序时省略了哪些 Log 方法?
- f# - 如何将有区别的联合作为函数中的参数传递?F#
- html - 为什么我不能更改容器的宽度?
- amazon-web-services - 如何在不使用 terraform 中的计数的情况下获取列表中的多个值?
- git - 如何重命名本地 Git 分支?
- python - 如何使用 python etree 重新创建此 XML 代码?
- flutter - Flutter:显示来自firestore的所有用户
- python - How to groupby and join, and then fillna from adjacent columns
- javascript - 如何检查 Typescript 对象数组中的多个值?