英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论