Or-tools: Python module ortools apparently installs incompletely

Created on 17 May 2019  路  6Comments  路  Source: google/or-tools

I am trying to set up ortools on my Mac.

I installed via pip install ortools. I can verify that the package installed successfully.

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

When I try to use the library, it looks like there are missing functions. I followed along with the example here:

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

This returns an error:

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

I can import the module otherwise and look at the functions interactively:

>>> 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__  

I just used tab complete here to see what was available. Sure enough there is no linear_solver attached to the ortools module.

I also tried building from source but this started failing at the make third_party step.

I'm a bit at a loss as to what to try next. Any advice would be appreciated.

Python

Most helpful comment

Hello,

I had a similar issue recently. Mine was because the given code example was done for an earlier version of ortools.
I am not sure the example has been updated.
You can maybe try to dowgrade to ortools < 7.0 .
Cheers,

All 6 comments

are you sure the conda python is 64 bit ?

It is 64 bit.

(linear_opt) S04557-MBPR:linear opto example my.name$ conda info

     active environment : linear_opt
    active env location : /anaconda3/envs/linear_opt
            shell level : 3
       user config file : /Users/my.name/.condarc
 populated config files : /Users/my.name/.condarc
          conda version : 4.6.11
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
       base environment : /anaconda3  (writable)
           channel URLs : http://conda.anaconda.org/gurobi/osx-64
                          http://conda.anaconda.org/gurobi/noarch
                          https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/osx-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /anaconda3/pkgs
                          /Users/my.name/.conda/pkgs
       envs directories : /anaconda3/envs
                          /Users/my.name/.conda/envs
               platform : osx-64
             user-agent : conda/4.6.11 requests/2.21.0 CPython/3.7.3 Darwin/18.5.0 OSX/10.14.4
                UID:GID : 651654757:832595117
             netrc file : None
           offline mode : False

Hello,

I had a similar issue recently. Mine was because the given code example was done for an earlier version of ortools.
I am not sure the example has been updated.
You can maybe try to dowgrade to ortools < 7.0 .
Cheers,

I was just thinking the same thing. I'll give it a shot and repot back what happens.

Yep, tried pip install ortools==6.7.4973 and things seem to be working again.

I confirmed that the above issue also resolves if I use Python 3.7 with the latest version of ortools.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

husamrahmanh2o picture husamrahmanh2o  路  4Comments

TeodoraB21 picture TeodoraB21  路  3Comments

CognitiveClouds-Prasad picture CognitiveClouds-Prasad  路  3Comments

unfuse picture unfuse  路  5Comments

abduakhatov picture abduakhatov  路  4Comments