【问题标题】:cannot use ortools from Google无法使用来自 Google 的 ortools
【发布时间】:2026-01-30 02:50:01
【问题描述】:

我按照these directions在运行 Mavericks (10.9.5) 的 macbook pro 上安装了工具或工具

我最初确实得到了这里描述的错误:can't install or-tools on mac 10.10

并遵循使用easy_install 的建议。是的,我确实收到了他们描述的错误,但似乎正确安装了工具。发行

import ortools

在python提示符下没有产生错误。

然后我去尝试谷歌提供的一个例子(见上面的第一个链接)并得到这个错误:

Traceback (most recent call last):
  File "examples/golomb8.py", line 26, in <module>
    from google.apputils import app
ImportError: No module named google.apputils

显然我错过了一些东西。谁能赐教??

【问题讨论】:

    标签: python-2.7


    【解决方案1】:

    您的问题是google.apputils 模块与ortools 是分开的,需要单独安装。您可以通过在 Google 提供的 repo 中运行一些其他示例来检查是否安装了 ortools,例如 python examples/map.py example in this repo 并确保 python optimize.py 产生预期的 NBA 阵容(这是我查看 ortools 的最初原因:-))。

    【讨论】:

    • 我可以在应用引擎上使用或工具
    • @GeorgeC。试试这个命令:python3 -m pip install --upgrade --user ortools。我在 gcp 始终免费层上做到了。
    最近更新 更多