ImportError with routing_enums_pb2

406 views
Skip to first unread message

Damien Lécole

unread,
Jun 21, 2016, 10:59:45 AM6/21/16
to or-tools-discuss
Hi everyone !!

I am new to or-tools. I am interested in testing 'cvrptw' solutions but I have issues running the examples. When running the crvptw.py script (the one from github), I get the following error :
"    from ortools.constraint_solver import routing_enums_pb2
ImportError: cannot import name routing_enums_pb2 "
I am not sure what to do...

I also tried the crvptw.py script from tar.gz file for the or-tools Python package. This script runs successfully (it doesn't use trouting_eums_pb2).

Any idea? Thanks in advance for your help.


Laurent Perron

unread,
Jun 21, 2016, 12:29:28 PM6/21/16
to or-tools-discuss
Hi, 

the script from v3574 did not use routing_enums_pb2.
What did you do with the github?

Can you do (in sequence)

make third_party
make install_python_modules
make python
make rpy EX=cvrptw

and report the errors?

Thanks

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Damien Lécole

unread,
Jun 21, 2016, 1:14:33 PM6/21/16
to or-tools-discuss
Hi Laurent,

Thanks for your answer.

I followed your procedure and get this error (which is the same as ealier):

Running python\\cvrptw.py
Traceback (most recent call last):
  File "examples/python\\cvrptw.py", line 43, in <module>
    from ortools.constraint_solver import routing_enums_pb2
ImportError: cannot import name routing_enums_pb2
C:\workspace\or-tools\or-tools-master\tools\make.exe: *** [rpy] Error 1

Otherwise with the code from gitHub, I followed the documentation without success. I tried many things : installing from binaries and from sources  so I am not sure to be able to point out precisely what was the problem.

Regards,
Damien  

Amit Kumar

unread,
Jun 22, 2016, 6:41:53 AM6/22/16
to or-tools-discuss
You can try changing the permission of the installed or-tools folder to 777 in the python path. That worked for me once.

Damien Lécole

unread,
Jun 22, 2016, 1:18:09 PM6/22/16
to or-tools-discuss
Thanks for your help Amit. I still get the error after settings the permissions.

I did a 'make clean' and retry the procedure described by Laurent. Then I ran the 'make all' command. In the documentation, it is written that the or-tools/bin and or-tools/lib folders should contain some specific files. I have everything apart from the C++ wrapping libraries. I am not sure what they are used for. Does it give a better understanding of the situation?

Laurent Perron

unread,
Jun 23, 2016, 12:45:34 PM6/23/16
to or-tools-discuss
Can you try:

sudo easy_install -U protobuf

Thanks

Driss Lahlou

unread,
Jun 24, 2016, 7:26:11 AM6/24/16
to or-tools...@googlegroups.com
Hello Damien,
Thank you for the report. If "sudo easy_install -U protobuf" doesn't work for you. (which was the case for me), please not that the problem is due to other installed versions of protobuf, which is already installed by the command "make install_python_modules".
So, what you need to do is : 
  1. pip uninstall protobuf (you need to have pip, because it's the recommanded way to uninstall a .egg)
  2. pip show protobuf (to make sure that you have no other versions of protobuf, so this command should NOT print anything)
  3. make install_python_modules (which will install the good version of protobuf)
We will be waiting for your feedback, and pleased to answer any other question
Regards

Damien Lécole

unread,
Jun 24, 2016, 8:44:42 AM6/24/16
to or-tools-discuss
Hi,

I appreciate your help.

The 'easy_install -U protobuf' command didn't work for me.

I followed your instructions to uninstall and install protobuf again. It did well but then running the example still gives me the same mistake as earlier. 
After make install_python_modules, the installed version of protobof is 3.0.0b3. Is it the correct one?

Driss Lahlou

unread,
Jun 24, 2016, 10:26:16 AM6/24/16
to or-tools...@googlegroups.com
Yes, it is the correct version.
I will try to get a closer look, and see what we can do about it. Thank you

Driss Lahlou

unread,
Jun 24, 2016, 12:46:57 PM6/24/16
to or-tools...@googlegroups.com
Okay, let's try this again
Can you run the following commands (after repeating the steps above) :
  1. PYTHONPATH=(OR_TOOLS_ROOT_PATH)/src
  2. python -v examples/python/cvrptw.py
Few more questions :
  • What OS are you using?
  • What python version are you using
  • Can you make sure you have the file src/gen/ortools/constraint_solver/routing_enums_pb2.pyc with right access permissions ?

Damien Lécole

unread,
Jun 27, 2016, 8:39:34 AM6/27/16
to or-tools-discuss
Hi Driss,

First of all :
  • OS: I migrated to Windows 10 last week
  • python : v2.7.6
  • permissions: it seems good to me
I tried to remove everything and then to start again from scratch but I had errors while re-installing. I have to clean all this before trying your solution.

Regards,
Damien

Driss Lahlou

unread,
Jun 27, 2016, 8:44:52 AM6/27/16
to or-tools...@googlegroups.com
Okay,

By the way, the -v option will tell you where pyhton fetches your modules, so this will give you an idea why it can't import routing_enums_pb2

Keep in touch

Damien Lécole

unread,
Jun 27, 2016, 10:42:02 AM6/27/16
to or-tools-discuss
Reinstalling from scratch didn't change anything to my problem. The python -v gives me this error :
Traceback (most recent call last):
  File "examples/python/cvrptw.py", line 43, in <module>

    from ortools.constraint_solver import routing_enums_pb2
ImportError: cannot import name routing_enums_pb2

The line before is 
import gflags # loaded from Zip C:\Python27\lib\site-packages\python_gflags-3.0.5-py2.7.egg\gflags\__init__.pyc
but it doesn't seem to be involved into the error
Reply all
Reply to author
Forward
0 new messages