问题描述
在 Windows 10 上的 VSCode 上使用 Gurobi。
import gurobipy as gp
from gurobipy import GRB
No name 'GRB' in module 'gurobipy'
但是在 Jupyter notebook 上做同样的事情不会出错。 我按照此处的说明使用 pip 安装了 gurobipy:https://support.gurobi.com/hc/en-us/articles/360044290292-Installing-Gurobi-for-Python
此外,我在 Jupyter Notebook 和系统中使用相同版本的 Python (3.9.1)(通过运行 python --version
检查)并且 pip freeze
显示安装了 gurobipy。