AttributeError: 创建MIP模型时,’NoneType’对象没有’split’属性

huangapple go评论75阅读模式
英文:

AttributeError: NoneType' object has no attribute 'split' when creating a mip model

问题

我相对来说对这个很新,但我想要使用Python-MIP来迈出我的第一步,所以我尝试按照示例进行操作。但每次我尝试创建一个模型时都会出现以下错误:

from mip import Model, BINARY
m = Model()

导致如下错误:

AttributeError                            Traceback (most recent call last)
Cell In[17], line 1
1 m = Model()

File ~\AppData\Roaming\Python\Python39\site-packages\mip\model.py:91, in Model.__init__(self, name, sense, solver_name, solver)
89     self.solver = mip.cbc.SolverCbc(self, name, sense)
90 else:
91     import mip.gurobi
93     if mip.gurobi.found:
95         self.solver = mip.gurobi.SolverGurobi(self, name, sense)

File ~\AppData\Roaming\Python\Python39\site-packages\mip\gurobi.py:75
72     lib_path = libfile[0]
74 # checking gurobi version
75 s1 = lib_path.split('"')[-1].split("/")
76 vs = [c for c in s1 if c.isdigit()]
77 major_ver = vs[0]

AttributeError: 'NoneType' object has no attribute 'split'

我最近安装了Gurobi,但一切都正常,所以我找不到我在这里做错了什么。

英文:

I am relatively new to this, but I wanted to do my first steps using Python-MIP, so I just tried to follow the first examples. But every time a just want to create a model the following error occurs:

from mip import Model, BINARY
m = Model()

results in:

AttributeError                            Traceback (most recent call last)
Cell In[17], line 1
1 m = Model()

File ~\AppData\Roaming\Python\Python39\site-packages\mip\model.py:91, in Model.__init__(self, name, sense, solver_name, solver)
89     self.solver = mip.cbc.SolverCbc(self, name, sense)
90 else:
91     import mip.gurobi
93     if mip.gurobi.found:
95         self.solver = mip.gurobi.SolverGurobi(self, name, sense)

File ~\AppData\Roaming\Python\Python39\site-packages\mip\gurobi.py:75
72     lib_path = libfile[0]
74 # checking gurobi version
75 s1 = lib_path.split('"')[-1].split("/")[-1]
76 vs = [c for c in s1 if c.isdigit()]
77 major_ver = vs[0]

AttributeError: 'NoneType' object has no attribute 'split'

I just recently installed Gurobi but everything was fine so I cant find point what I am doing wrong here.

答案1

得分: 1

在我之前也遇到过同样的问题。在我的情况下,不是Gurobi引起的问题,而是mip包。所以重新安装解决了我的问题。

英文:

Had the same problem some time ago. In my case Gurobi was not the reason, but the mip package. So reinstalling did it for me.

huangapple
  • 本文由 发表于 2023年3月21日 00:47:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793075.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定