首页 > 解决方案 > Python 模块 ortools 显然安装不完整

问题描述

我正在尝试ortools在我的 Mac 上进行设置。

我通过pip install ortools. 我可以验证包安装成功。

 conda list | grep ortools
WARNING: The conda.compat module is deprecated and will be removed in a future release.
ortools                   7.1.6720                 pypi_0    pypi

当我尝试使用该库时,似乎缺少功能。我跟着这里的例子:

https://developers.google.com/optimization/introduction/python

这将返回一个错误:

from __future__ import print_function
from ortools.linear_solver import pywraplp

Traceback (most recent call last):
  File "simple_ortools_example.py", line 2, in <module>
    from ortools.linear_solver import pywraplp
ImportError: No module named ortools.linear_solver

否则我可以导入模块并以交互方式查看函数:

>>> ortools.__
ortools.__cached__          ortools.__gt__(             ortools.__path__
ortools.__class__(          ortools.__hash__(           ortools.__reduce__(
ortools.__delattr__(        ortools.__init__(           ortools.__reduce_ex__(
ortools.__dict__            ortools.__init_subclass__(  ortools.__repr__(
ortools.__dir__(            ortools.__le__(             ortools.__setattr__(
ortools.__doc__             ortools.__loader__          ortools.__sizeof__(
ortools.__eq__(             ortools.__lt__(             ortools.__spec__
ortools.__file__            ortools.__name__            ortools.__str__(
ortools.__format__(         ortools.__ne__(             ortools.__subclasshook__(
ortools.__ge__(             ortools.__new__(            ortools.__version__
ortools.__getattribute__(   ortools.__package__   

我只是在这里使用了 tab complete 来查看可用的内容。果然,ortools 模块没有附加 linear_solver。

我有点不知所措,不知道下一步该尝试什么。任何建议都将不胜感激。

标签: pythonor-tools

解决方案


我降级到解决问题的早期版本。

pip install ortools==6.7.4973


推荐阅读