你可以用三种不同的方式安装用于Python的Gurobi优化器:
1.皮普
从Gurobi 9.1开始,你可以使用pip将Gurobi安装到你当前活动的Python环境中:
安装gurobipy
Pip是安装Python包的标准方式,应该可以在大多数平台和系统上工作。使用此命令安装特定版本:
Python -m PIP安装gurobipy==9.5.0
注意:pip安装方法中不提供Gurobi license工具。如果您还没有在您的机器上设置许可证,那么您将需要使用其他安装方法之一或安装license工具包.
2.conda
如果你正在使用蟒蛇Python,你可以通过Gurobi的conda通道安装:
Conda安装-c gurobi
使用此命令安装特定版本:
Conda安装-c gurobi gurobi=9.5.0
注意:Gurobi并不适用于所有Python版本(完整的列表).
3.setup . py
安装完整的Gurobi Optimizer包。
- 从我们的网站下载并安装完整的Gurobi安装包.
- 在你的shell/终端,导航到Gurobi安装文件夹(GUROBI_HOME),并运行:
python setup . py install
请注意:如果您正在使用虚拟环境,请确保在安装Gurobi之前激活虚拟环境。
安装方法的特点及差异如下表所示:
皮普 | conda | 完整的安装程序 | |
不需要Windows管理员权限 | ✅ | ✅ | ❌ |
可以使用Python以外的api吗 | ❌ | ❌ | ✅ |
Docker的简单设置 | ✅ | ✅ | ❌ |
Gurobi许可工具(grbgetkey, grbprobe) | ❌ | ✅ | ✅ |
古罗比shell(古罗比.sh或古罗比.bat) | ❌ | ❌ | ✅ |
Gurobi命令行工具(gurobi_cl, grbcluster, grbtune, grb_ts) | ❌ | ✅ | ✅ |
离线安装 | ❌ | ❌ | ✅ |