Error when loading python module (noob)

1,946 views
Skip to first unread message

Jose Antonio Medrano Garcia

unread,
Jan 31, 2014, 9:41:18 AM1/31/14
to or-tools...@googlegroups.com
Hello, I downloaded the ortools module for python from pypi and I executed the file, everything was OK, no errors or warnings.  When I try the examples I get the following error:

>>> from ortools.linear_solver import pywraplp

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from ortools.linear_solver import pywraplp
  File "C:\Python27\lib\site-packages\ortools\linear_solver\pywraplp.py", line 28, in <module>
    _pywraplp = swig_import_helper()
  File "C:\Python27\lib\site-packages\ortools\linear_solver\pywraplp.py", line 20, in swig_import_helper
    import _pywraplp
ImportError: No module named _pywraplp

Am I missing something?

Laurent Perron

unread,
Jan 31, 2014, 9:43:43 AM1/31/14
to or-tools...@googlegroups.com
is this a 32 bit python?  Did you download the 32 bit module?

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/groups/opt_out.

Jose Antonio Medrano Garcia

unread,
Jan 31, 2014, 10:22:23 AM1/31/14
to or-tools...@googlegroups.com
I am using Python(x,y) on a Windows XP virtual machine within Virtualbox and yes, I downloaded the 32 bit module

Laurent Perron

unread,
Jan 31, 2014, 10:27:19 AM1/31/14
to or-tools...@googlegroups.com
can you check you have _pywraplp.pyd in C:\Python27\lib\site-packages\ortools\linear_solver\ ?

Thanks

Jose Antonio Medrano Garcia

unread,
Jan 31, 2014, 10:46:51 AM1/31/14
to or-tools...@googlegroups.com
There are 3 files with the name pywraplp but none of them has the .pyd extension, also none of them has the leading underscore in the name...

Laurent Perron

unread,
Jan 31, 2014, 12:37:36 PM1/31/14
to or-tools-discuss

It should be an old archive.
Please try to download the python examples archives (3070) and run python setup.py install inside it.

Thanks

Jose Antonio Medrano Garcia

unread,
Jan 31, 2014, 3:01:18 PM1/31/14
to or-tools...@googlegroups.com
Thanks, but where do I download those files from?

Laurent Perron

unread,
Jan 31, 2014, 3:28:44 PM1/31/14
to or-tools-discuss

Jose Antonio Medrano Garcia

unread,
Jan 31, 2014, 5:36:00 PM1/31/14
to or-tools...@googlegroups.com
Thanks, did that, got the following error:


Jose Antonio Medrano Garcia

unread,
Feb 1, 2014, 3:31:29 PM2/1/14
to or-tools...@googlegroups.com
I downloaded the .egg file from pypi, reinstalled in a different machine, not in the virtualbox virtual machine and still keep getting the same error, is there a problem with the installation module for python?


Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from constraint_solver import pywrapcp

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from constraint_solver import pywrapcp
ImportError: No module named constraint_solver
>>> 
>>> from ortools.constraint_solver import pywrapcp

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from ortools.constraint_solver import pywrapcp
  File "C:\Python27\lib\site-packages\ortools-1.3107-py2.7-win32.egg\ortools\constraint_solver\pywrapcp.py", line 28, in <module>
    _pywrapcp = swig_import_helper()
  File "C:\Python27\lib\site-packages\ortools-1.3107-py2.7-win32.egg\ortools\constraint_solver\pywrapcp.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrapcp', fp, pathname, description)
ImportError: DLL load failed: The specified module could not be found.

Laurent Perron

unread,
Feb 2, 2014, 2:18:24 PM2/2/14
to or-tools...@googlegroups.com
It works flawlessly on my machine.
I tried python setup.py install and python setup.py install --user. Both works fine.

Normally, it you run setup.py install inside the examples archive, it will pull the python binary egg module and install it.

Can you try this?

Thanks

Jose Antonio Medrano Garcia

unread,
Feb 3, 2014, 1:00:46 PM2/3/14
to or-tools...@googlegroups.com
I have tried all your suggestions, I have installed the module from the exe file, from the egg file, from the ortools_example file, I have done it in 3 different machines and I always get the same error message about the module not found. I even reinstalled it from easy_install, with 2 different python installations (enthought and pythonxy). On the other hand, I installed it in Ubuntu with easy_install and it worked perfectly, so I´m about to give up on the windows installation. Any other suggestions?

Laurent Perron

unread,
Feb 3, 2014, 1:24:48 PM2/3/14
to or-tools...@googlegroups.com
Hello, 

Can you make sure you have the C++ redistributable libraries for visual studio 2012 installed?
Maybe this is what makes the loading of modules fail.

--Laurent

Jose Antonio Medrano Garcia

unread,
Feb 3, 2014, 5:05:58 PM2/3/14
to or-tools...@googlegroups.com
I have the VS C++ redistributables installed for 2005, 2008 and 2010 but not 2012.

Jose Antonio Medrano Garcia

unread,
Feb 3, 2014, 9:02:04 PM2/3/14
to or-tools...@googlegroups.com
In one of the windows machines I do have the VS C++ redistributables for 2012 and still it does not work. I don't know what else to do,  I guess I will have to give up on windows and move to ubuntu.

Laurent Perron

unread,
Feb 4, 2014, 2:05:02 AM2/4/14
to or-tools...@googlegroups.com
Hi again, 

can you try adding -v -m to the python command line flags.
It should log the module loading process.

Thanks

Jose Antonio Medrano Garcia

unread,
Feb 4, 2014, 10:10:54 AM2/4/14
to or-tools...@googlegroups.com
thanks, how and where exactly do I do that?  

Jose Antonio Medrano Garcia

unread,
Feb 12, 2014, 8:02:43 PM2/12/14
to or-tools...@googlegroups.com
I have been reading through the posts and it is not an isolated issue, I found other people having the same problem.  There seems to be a bug in the setup.py file which we are supposed to change manually (change the dll for pyd and add other stuff) but I can´t seem to find the setup.py file to make those changes since I installed the module through easy_install or via the egg file.  I really want to give this thing a try for my OR classes and use it for discrete optimization but I have not been able to get it running.

Laurent Perron

unread,
Feb 13, 2014, 5:45:34 PM2/13/14
to or-tools...@googlegroups.com
No, 

I fixed the bug with pyd a while ago. And I tested these modules on my computer and they were fine.
Therefore it is harder to debug.

Laurent Perron

unread,
Feb 13, 2014, 5:49:06 PM2/13/14
to or-tools...@googlegroups.com
so please run c:\python27\python.exe -v -m <path to one example>

Can you try pyflow_example.py ? It has less dependencies than the pywraplp module.

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discuss+unsubscribe@googlegroups.com.

Jose Antonio Medrano Garcia

unread,
Feb 13, 2014, 8:10:16 PM2/13/14
to or-tools...@googlegroups.com
OK, I did that but the output is very long and I don´t know how to copy it from the command window, and also when I scroll up the first part of the output is no longer available.   Here's what I typed at the command line

c:>python -v -m pyflow_example.py

(I am in the examples directory so I don't have to specify the path)

and attached is the last part of the output as an image, since I can't copy it



El jueves, 13 de febrero de 2014 16:49:06 UTC-6, Laurent Perron escribió:
so please run c:\python27\python.exe -v -m <path to one examp

error.jpg

Laurent Perron

unread,
Feb 14, 2014, 10:19:14 AM2/14/14
to or-tools...@googlegroups.com
Hello,

I have rebuilt the packages with different options.
The version number is now 3149.

Can you retry?

Thanks

Jose Antonio Medrano Garcia

unread,
Feb 14, 2014, 1:30:54 PM2/14/14
to or-tools...@googlegroups.com
thanks, sorry to tell you that I deleted all files in  the site-packages ortools folder, reinstalled the new package and still the problem persists...

Laurent Perron

unread,
Feb 14, 2014, 3:35:03 PM2/14/14
to or-tools...@googlegroups.com
Maybe it is the manual install.

Here is what I did:
download Google.OrTools.python.examples.3124.zip from https://drive.google.com/folderview?id=0B2yUSpEp04BNdEU4QW5US1hvTzg&usp=sharing#list

unzip it somewhere

go into directory ortools_examples and type:
  c:\python27\python.exe setup.py install

this pulls ortools 1369 along other dependencies. then type:

  c:\python27\python.exe examples\pyflow_example.py

and it works.

Can you try that?

Thanks

Jose Antonio Medrano Garcia

unread,
Feb 14, 2014, 9:50:25 PM2/14/14
to or-tools...@googlegroups.com
sorry man, no go, erased everything, did exactly as you suggested and still the same error...I appreciate all your help, but I have tried this in 2 different machines, one with xp and one with win7 with the same results...

Fabien Valthier

unread,
Sep 5, 2014, 2:30:05 AM9/5/14
to or-tools...@googlegroups.com
Hi,

I believe I have the same type of error.
I just installed or-tools and when I tried to run an example,
I get the following error:

>python.exe examples\golomb8.py
raceback (most recent call last):
 File "examples\golomb8.py", line 28, in <module>
   from ortools.constraint_solver import pywrapcp
 File "c:\python27\lib\site-packages\ortools-1.3750-py2.7-win32.egg\or
traint_solver\pywrapcp.py", line 27, in <module>
   _pywrapcp = swig_import_helper()
 File "c:\python27\lib\site-packages\ortools-1.3750-py2.7-win32.egg\or
traint_solver\pywrapcp.py", line 23, in swig_import_helper
   _mod = imp.load_module('_pywrapcp', fp, pathname, description)
mportError: DLL load failed: The specified module could not be found.

However, the *.pyd is in the constraint_solver directory.
I tried several things but did not work. 
Anyone has an idea on the issue ?

(I am on Win7 x64 (but for some reasons ortools win32 was installed,
Python 2.7)

Thank you very much !

Laurent Perron

unread,
Sep 8, 2014, 8:45:39 AM9/8/14
to or-tools...@googlegroups.com
First part of the answer, the library that you are using is linked to the python version (32 or 64 bit)
I will install a module and try it.

--Laurent

For more options, visit https://groups.google.com/d/optout.

Vivek Vikram Singh

unread,
Apr 16, 2015, 10:01:07 PM4/16/15
to or-tools...@googlegroups.com
Hi,
I had the exact same problem with " pywrapcp ", but I played stupid myself. So felt kind of giving up. Then tried these steps mentioned here
Windows7 ,64 bit, Python 2.7
1) installed Visual Studio 2012 ultimate
2) I already had JDK 1.7
3) Downloaded and installed CMake 2.8
4) Downloaded and installed " setuptools " ( did not install GLPK )
5) Downloaded and install " google-apputils " 
Run example (tsp.py) in or-tools/example directory, it worked fine.

I suggest you to erase everything relared to this process and start once more. It might work. Worked for me after 14 hours continuos work.

Shuo Li

unread,
Aug 23, 2015, 4:25:21 AM8/23/15
to or-tools-discuss
I had this problem on my new Win10 x86-64 machine as well

ImportError: DLL load failed: The specified module could not be found.

After exploring the _pywrapcp.pyd file using dependency walker, I found the VC++ packages are missing.
Install Visual C++ Redistributable Packages for Visual Studio 2013 and problem solved.



在 2015年4月17日星期五 UTC+2上午4:01:07,Vivek Vikram Singh写道:

Lei Feng

unread,
Jan 14, 2016, 3:33:58 PM1/14/16
to or-tools-discuss
Installing Visuall C++ Redistributable Packages works for me too. Thanks for sharing!
Reply all
Reply to author
Forward
0 new messages