gurobipy - 模块“gurobipy”中没有名称“GRB”

问题描述

在 Windows 10 上的 VSCode 上使用 Gurobi。

我有以下代码

import gurobipy as gp
from gurobipy import GRB

现在有趣的是,当我将其放入 .py 文件时,我收到错误

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。

解决方法

我已经找到了解决方法。

https://medium.com/@haominnn/how-to-deal-with-python-not-finding-tensor-flow-module-under-anaconda-3aefa8ffae11

基本上只是禁用 pylint 并替换为 pep8。

pep8 的媒体链接已过时,请改用 VS Code doesn't recognize pep8