Error on install for Python 2.7 on Windows: _pywrapcpp.dll ...

864 views
Skip to first unread message

Jean-Victor Côté

unread,
Jul 1, 2013, 1:06:56 PM7/1/13
to or-tools...@googlegroups.com
... doesn't exist or not a regular file.  Also, a closing parenthesis is missing on line 16 of setup.py  Both of these problems occur in the constraint_solver directory, so to speak.  It so happens that this is one set of tools that I desperately need.

Josyula Krishna

unread,
Jul 3, 2013, 9:31:35 AM7/3/13
to or-tools...@googlegroups.com
Replace all .dll to .pyd in the setup.py file. that fixes the problem. 

Patrick O'Brien

unread,
Jul 9, 2013, 6:47:13 AM7/9/13
to or-tools...@googlegroups.com
Hi,

Hi,

I am running python 2.7 in cygwin on windows 7 x64, I did manage to get or-tools 
installed via setup.py install.
I did have to fix the script adding the parentheses and changing the 
.dll to .pyd. The install script completed successfully.

However I am still not able to get the examples work.
I am getting this error:


/cygdrive/c/Development/libs_python/or-tools.Windows64/examples
$ python coloring_ip.py
Traceback (most recent call last):
   File "coloring_ip.py", line 41, in <module>
     from linear_solver import pywraplp
   File 
"/usr/lib/python2.7/site-packages/or_tools-1.0.2322-py2.7.egg/linear_solver/pywraplp.py", 
line 26, in <module>
     _pywraplp = swig_import_helper()
   File 
"/usr/lib/python2.7/site-packages/or_tools-1.0.2322-py2.7.egg/linear_solver/pywraplp.py", 
line 18, in swig_import_helper
     import _pywraplp
ImportError: No module named _pywraplp

Any idea what it could be?

Please advise.

Thanks

fbahr

unread,
Sep 29, 2013, 11:05:31 AM9/29/13
to or-tools...@googlegroups.com
Same issue here.

Setup:
- Windows XP SP3
- Python 2.7.5 (clean)
- setuptools-116

Then:
- Downloaded Google.OrTools.python.VisualStudio2012-32b.2907.zip
- Fixed the setup.py script (s/dll/pyd)
- Downloaded & installed MS Visual C++ 2012 Redistributable (x86) [v.11.0.60601]
  (which puts msvcp110.dll, msvcr110.dll in C:\WINDOWS\system32)
- installed setuptools, ran or-tool's setup.py

Installation finished smoothly, all dependencies processed.

PATH includes C:\WINDOWS and C:\WINDOWS\system32; PYTHONPATH is C:\Programme\Python27;C:\Programme\Python27\Scripts.

Yet, when testing examples\who_killed_agatha.py, I get:


Traceback (most recent call last):
  File "examples\who_killed_agatha.py", line 63, in <module>
    from constraint_solver import pywrapcp
  File "C:\Programme\Python27\lib\site-packages\or_tools-1.0.2907-py2.7.egg\constraint_solver\pywrapcp.py", line 26, in <module>
    _pywrapcp = swig_import_helper()
  File "C:\Programme\Python27\lib\site-packages\or_tools-1.0.2907-py2.7.egg\constraint_solver\pywrapcp.py", line 22, in swig_import_helper
    _mod = imp.load_module('_pywrapcp', fp, pathname, description)
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.

I'm probably missing something very basic here... any idea what it is?

fbahr

Laurent Perron

unread,
Sep 30, 2013, 1:01:15 PM9/30/13
to or-tools-discuss
So python does not find the pyd. 
I will debug. In the meantime, you can use it by setting PYTHONPATH to point to the installation src file.

Thanks

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



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

Gary Bentley

unread,
Oct 14, 2016, 7:05:58 PM10/14/16
to or-tools-discuss
I don't know if you finally solved this problem, but I thought I would post the fix in my own case, in the hope it will save someone some time in the future. I am running python 2.7 MSC v.1500 64 bit (AMD64)] on win32 (Active State old free version on Windows 8). I followed the Google install instructions online, downloading the zipped archive https://github.com/google/or-tools/releases/download/v4.3/or-tools.python.examples_4.3.3805.zip. I unpacked that in a directory in my Python directory ("C:\Python27\Lib\ortools_examples") and then ran python.exe setup.py install (while Internet connection up). I ran the depency check and it looked ok.

However, when I attempted to run "C:\Python27\Lib\ortools_examples\examples\python\zebra.py", I got an error:
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _pywrapcp

I was running in the Pythonwin debugger environment supplied with ActiveState Python 2.7. I stepped through execution on another run, assuring that the scripts were finding the file in "C:\Python27\Lib\site-packages\ortools-4.4.3842-py2.7-win-amd64.egg\ortools\constraint_solver\_pywrapcp.pyd". Interestingly, when I stepped into the C:\Python27\lib\importlib\__init__.py", line 37  __import__(name) statement (which was where the fail point was occuring) this time I got an "ImportError: DLL load failed: The specified module could not be found." (When I had been executing zebra.py in Python directly I got only the "couldn't find" error.) I note that I did add a PYTHONPATH system environment variable in my Windows system to assure it could find the constraint solver files, but that was not a problem. This more detailed error suggested to me that there was something about the Python dll file (_pywrapcp.pyd) that it choked on.

I spend days researching the problem (I hadn't been a Python user previously, though was a software engineer in the 1980's) and finally got hold of a tool that allowed me to see what _pywrapcp.pyd wanted, i.e., what files it depended on. The tool was dependencywalker. This tool is not completely accurate on later Windows systems like mine (Windows 8), for example, when I ran it against one of the Python installation pyd files in another directory it claimed that the file couldnt locate MSVCR90.DLL, i.e., the Microsoft Visual C runtime Version 9.0. I knew this was not correct since I tested the file with C:\Python27\Lib\test\test_ctypes.py and it passed. However, dependencywalker was at least telling me what MS C runtime version the pyd file wanted, so I ran it against _pywrapcp.pyd and it told me it wanted MSVCP140.DLL. This is the MS C runtime version 14.0, the 2015 Visual Studio C runtime distributable.

I checked my system in Add/Remove Programs and I did not have the 2015 C runtimes, though had 2005 - 2012 versions. I realized that or-tools was probably compiled with the latest MSVC version so I installed the MS 2015 MSVC runtime from https://www.microsoft.com/en-us/download/details.aspx?id=48145 (free). Some may suggest I should have always been installing updates and might have picked it up without the problems, but as for myself I don't trust Microsoft and don't let them install anything anytime. 2015 MSVC had telemetry hidden in it for a while, since removed (I hope), so my concerns were not unfounded.

To make a long story short (probably too late, grin), after I installed the 2015 C runtime (went ahead and installed x86 and x64---doesn't really matter how many versions you have---I'm running 64 bit but wanted to assure everyone was happy, whatever they wanted) I ran zebra.py and was pleased to learn that "The norwegian drinks water. and the japanese owns the zebra." That is the contraint problem solution I assume (too tired to dig into the actual solver usage today).


So, if anyone is having an error claiming that one of the _pywrapxx.pyd files can't be found, after you assure you have namespace available, proper paths to your Python directories, take a look at your Windows Add/Remove Programs and assure you have the latest MS Visual C redistributables. It doesn't cause any harm to install those and they are free. It is likely or-tools is always going to use the latest.

DataScience Tanios

unread,
Feb 26, 2018, 11:30:03 AM2/26/18
to or-tools-discuss

I suffered from the same bug (ImportError: No module named _pywrapcp) using Python 3.6.4 64bit and ortools 6.6.4656.
The same solution fixed my problem. (install Visual C++ Redistributable for Visual Studio 2015 )

Thank you so much Gary Bentley!

Gary Bentley

unread,
Mar 3, 2018, 12:27:55 PM3/3/18
to or-tools...@googlegroups.com
March 3, 2018
Glad the post was helpful. Hope you accomplish much with ortools.
Gary

--
You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/WQ1sddjVXHU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages