简体   繁体   English

在 Google Colab 上为 python 安装 GLPK

[英]Install GLPK on Google Colab for python

I want to use Pyomo in Google Colab.我想在 Google Colab 中使用 Pyomo。

I did this:我这样做了:

pip install pyomo #works 100%
pip install glpk  #error

the error is:错误是:

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错误:无法为 glpk 构建轮子为 glpk 运行 setup.py clean 无法构建 glpk 错误:无法为使用 PEP 517 且无法直接安装的 glpk 构建轮子

Usually we recommend installing glpk using conda.通常我们建议使用 conda 安装 glpk。 I'm not sure if Google Colab has conda installed but if so the command would be:我不确定 Google Colab 是否安装了 conda,但如果是,命令将是:

conda install -c conda-forge glpk

Also, I recommend taking a look at Chapter 1 of the Pyomo cookbooks here which describe how to set up solvers to use with Pyomo and include notebooks that can be run in Google Colab.另外,我建议在这里查看Pyomo 食谱的第 1 章,其中描述了如何设置求解器以与 Pyomo 一起使用,并包括可以在 Google Colab 中运行的笔记本。

Need to use both apt and pip to install it.需要同时使用 apt 和 pip 来安装它。

!pip install pyomo
!apt install glpk-utils
!pip install glpk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM