最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why can pywrapgraph from ortools.graph not be imported? - Stack Overflow

programmeradmin0浏览0评论

I am trying to run a graph optimization with the ortools library in Python. I have installed the latest version via pip install in a conda environment but still, I get this very unspecific error of a failed import of ortool's pywrapgraph module:

Exception has occurred: ImportError
cannot import name 'pywrapgraph' from 'ortools.graph' (c:\Users\user\AppData\Local\miniconda3\envs\ROME\Lib\site-packages\ortools\graph\__init__.py)
  File "D:\automation\optimizeGraphGoogleOR.py", line 3, in <module>
    from ortools.graph import pywrapgraph
ImportError: cannot import name 'pywrapgraph' from 'ortools.graph' (c:\Users\user\AppData\Local\miniconda3\envs\ROME\Lib\site-packages\ortools\graph\__init__.py)

I have already tried some other versions, but the error keeps persisting, any clue on how to fix that? Thanks!

I have already tried installing different versions and expected that to fix the issue, but running the command from ortools.graph import pywrapgraph still results in an error message.

I am trying to run a graph optimization with the ortools library in Python. I have installed the latest version via pip install in a conda environment but still, I get this very unspecific error of a failed import of ortool's pywrapgraph module:

Exception has occurred: ImportError
cannot import name 'pywrapgraph' from 'ortools.graph' (c:\Users\user\AppData\Local\miniconda3\envs\ROME\Lib\site-packages\ortools\graph\__init__.py)
  File "D:\automation\optimizeGraphGoogleOR.py", line 3, in <module>
    from ortools.graph import pywrapgraph
ImportError: cannot import name 'pywrapgraph' from 'ortools.graph' (c:\Users\user\AppData\Local\miniconda3\envs\ROME\Lib\site-packages\ortools\graph\__init__.py)

I have already tried some other versions, but the error keeps persisting, any clue on how to fix that? Thanks!

I have already tried installing different versions and expected that to fix the issue, but running the command from ortools.graph import pywrapgraph still results in an error message.

Share Improve this question asked Jan 30 at 6:13 Henry FischerHenry Fischer 211 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 3

Changed in release 9.4 and described in the release notes:

https://github/google/or-tools/releases/tag/v9.4

The pywrapgraph is deprecated and has been removed from recent versions of OR-Tools.
Now to import the new modules you have to use

from ortools.graph.python import min_cost_flow
from ortools.graph.python import max_flow
from ortools.graph.python import linear_sum_assignment
发布评论

评论列表(0)

  1. 暂无评论