Python 模块 ortools 显然安装不完整
Python module ortools apparently installs incompletely
我正在尝试在我的 Mac 上设置 ortools
。
我是通过 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
这returns一个错误:
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 来查看可用的内容。果然没有 linear_solver 附加到 ortools 模块。
对于接下来要尝试什么,我有点不知所措。如有任何建议,我们将不胜感激。
我降级到较早的版本解决了问题。
pip install ortools==6.7.4973
我今天在 Windows 遇到了同样的问题。发现通常是由于缺少 Microsoft Visual Studio 20** redistributables c++ (see here).
我就是这样解决的(Python 3.7.6,ortools 版本:7.5.*)。
- 从 https://support.microsoft.com/en-my/help/2977003/the-latest-supported-visual-c 获得了最新的 Microsoft Visual Studio 20** 可再发行 c++
下载
- 已安装并重新启动计算机。
- 卸载 ortools 'python -m pip uninstall ortools'
- 重新安装 ortools 'python -m pip install --user ortools'
- 使用 python -c "from ortools.linear_solver import pywraplp"
验证安装
我正在尝试在我的 Mac 上设置 ortools
。
我是通过 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
这returns一个错误:
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 来查看可用的内容。果然没有 linear_solver 附加到 ortools 模块。
对于接下来要尝试什么,我有点不知所措。如有任何建议,我们将不胜感激。
我降级到较早的版本解决了问题。
pip install ortools==6.7.4973
我今天在 Windows 遇到了同样的问题。发现通常是由于缺少 Microsoft Visual Studio 20** redistributables c++ (see here).
我就是这样解决的(Python 3.7.6,ortools 版本:7.5.*)。
- 从 https://support.microsoft.com/en-my/help/2977003/the-latest-supported-visual-c 获得了最新的 Microsoft Visual Studio 20** 可再发行 c++ 下载
- 已安装并重新启动计算机。
- 卸载 ortools 'python -m pip uninstall ortools'
- 重新安装 ortools 'python -m pip install --user ortools'
- 使用 python -c "from ortools.linear_solver import pywraplp" 验证安装