Hello,
I have successfully installed ortools via pip, with compatible versions of Python (3.6.3, 64-bit) and pip (9.0.1).
When I call "python my_program.py" to test the sample python code on this webpage: https://developers.google.com/optimization/introduction/run_programs
I get the following error message:
ModuleNotFoundError: No module named '_pywraplp'.
I've been struggling with this, so if anyone can remedy the problem, that would be great!
Thanks!
Hi,
Did you only have this line ?
pywraplp.py is a python linear_solver which wrap _pywraplp.so library which is linked with libortools.so
I reproduce this kind of error having _pywraplp.so with incorrect link...
To verify if _pywraplp is correctly link:
$> pip show ortools
[...]
Location: /usr/local/google/home/corentinl/.local/lib/python3.5/site-packages
$> cd /usr/local/google/home/corentinl/.local/lib/python3.5/site-packages/ortools/linear_solver
$> ldd _pywraplp.so
[...]
libortools.so => not found
Actually there is a libortools-3bbb0a68.so in .../site-packages/ortools/.libs/
Try to uninstall everything and reinstall ortools
pip uninstall ortools (until you have the message "Cannot uninstall requirement ortools, not installed')sudo pip uninstall ortools (until you have the message "Cannot uninstall requirement ortools, not installed')pip show ortools should return an error (1)pip install --user ortoolsNow ldd should return
$> cd .local/lib/python3.5/site-packages/ortools/linear_solver
$> ldd _pywraplp.so
[...]
libortools-3bbb0a68.so => [...]/./../.libs/libortools-3bbb0a68.so
note: You can also test everything is fine using python3 -c "import ortools.linear_solver.pywraplp"
When I did the uninstall ortools and reinstall, I got the following:
C:\Users\markw_000\Documents>pip show ortools
Name: ortools
Version: 6.6.4656
Summary: Google OR-Tools python libraries and modules
Home-page: https://developers.google.com/optimization/
Author: Google Inc
Author-email: [email protected]
License: Apache 2.0
Location: c:\users\markw_000\appdata\roaming\python\python36\site-packages
Requires: protobuf, six
Also, I noted that there's no /.libs/ folder within /ortools/
Hi again,
So you are on windows.
According to this https://github.com/google/or-tools/blob/master/tools/setup.py#L52
I would say libortools is not shipped with the windows python binary package, but i'm still new on the project, so I need to dig a little bit more and double check to confirm...
EDIT: on windows ortools is built as static and integrated in each _pywrapXXX that's why you don't have any libortools.dll, since library is built on linux with default visibility, there is no export macro -> only static link is working IMHO...
My best guess: Try to also install 'or-tools C++' windows installer and see what's happen...
BTW I will look at it, since we would like to have python package shipped with everything needed (not only wrapper to the libortools.dll/.so but a standalone package)
seems related to #556. Should be fixed on head now
Using v6.7 everything seems to work (using a VS2017 x64 prompt)
[Setup]
> set path
Path=...C:\python36-64;C:\python36-64\Scripts;...
> where python
C:\python36-64\python.exe
> python --version
Python 3.6.3
> python -c "import platform; print(platform.architecture())"
('64bit', 'WindowsPE')
> python -m pip list
no or-tools...
> python -m pip install ortools
...
Installing collected packages: ... ortools
Successfully installed ortools-6.7.4957 ...
Then create a file my_program.py containing code at https://developers.google.com/optimization/introduction/run_programs
> type my_program.py
from __future__ import print_function
from ortools.linear_solver import pywraplp
def main():
solver = pywraplp.Solver('SolveSimpleSystem',
pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
x = solver.NumVar(0, 1, 'x')
y = solver.NumVar(0, 2, 'y')
objective = solver.Objective()
objective.SetCoefficient(x, 1)
objective.SetCoefficient(y, 1)
objective.SetMaximization()
solver.Solve()
print('Solution:')
print('x = ', x.solution_value())
print('y = ', y.solution_value())
if __name__ == '__main__':
main()
Try running it:
> python my_program.py
Solution:
x = 1.0
y = 2.0
So for me, it solved with the version v6.7.
Feel free to open issue if needed
I installed OR-Tools using the installer that comes with PyCharm. I am using 6.8.5452 version of OrTools, but I still get the same error. Here's what I am trying to run:
from ortools.linear_solver import pywraplp
def main():
# Instantiate a mixed-integer solver
solver = pywraplp.Solver('NonRooftopPVAllocation',
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
# x and y are integer non-negative variables.
x = solver.IntVar(0.0, solver.infinity(), 'x')
y = solver.IntVar(0.0, solver.infinity(), 'y')
And here's the error I am getting:
Traceback (most recent call last):
File "C:\Users\..\PycharmProjects\..\..\lib\site-packages\ortools\linear_solver\pywraplp.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\,,\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm 2018.2.1\helpers\pydev\_pydev_bundle\pydev_umd.py", line 194, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2018.2.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
Did you install visual studio redistributables ?
Are you using a 64 bit version of Python?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mar. 18 sept. 2018 à 17:56, Sayon notifications@github.com a écrit :
I installed OR-Tools using the installer that comes with PyCharm. I am
using 6.8.5452 version of OrTools, but I still get the same error. Here's
what I am trying to run:from ortools.linear_solver import pywraplp
def main():
# Instantiate a mixed-integer solver
solver = pywraplp.Solver('NonRooftopPVAllocation',
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)# x and y are integer non-negative variables. x = solver.IntVar(0.0, solver.infinity(), 'x') y = solver.IntVar(0.0, solver.infinity(), 'y')And here's the error I am getting:
Traceback (most recent call last): File "C:\Users\..\PycharmProjects\..\..\lib\site-packages\ortools\linear_solver\pywraplp.py", line 14, in swig_import_helper return importlib.import_module(mname) File "C:\Users\,,\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 658, in _load_unlocked File "<frozen importlib._bootstrap>", line 571, in module_from_spec File "<frozen importlib._bootstrap_external>", line 922, in create_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm 2018.2.1\helpers\pydev\_pydev_bundle\pydev_umd.py", line 194, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:\Program Files\JetBrains\PyCharm 2018.2.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/541#issuecomment-422448546,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKj17T2wwWF3PN7d7PnUwfQfbgUkXKlpks5ucRe4gaJpZM4Q-MCe
.
Hello Iperron,
I am using Python v 3.6.0 64 bit. Can you share the link to the VS Redistributable package you are referring to?
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
choose 64 bit version.
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mar. 18 sept. 2018 à 18:36, Sayon notifications@github.com a écrit :
Hello Iperron,
I am using Python v 3.6.0 64 bit. Can you share the link to the VS
Redistributable package you are referring to?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/541#issuecomment-422462107,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKj17Z-z8Qinkxu5WBbOm69AatDDs-dsks5ucSEDgaJpZM4Q-MCe
.
Hello all,
I have similar issue on cygwin. Module is there, but it can't import it for some reason...
$ pip3 show py3-ortools
Name: py3-ortools
Version: 5.1.4041
Summary: Google OR-Tools python libraries and modules
Home-page: https://developers.google.com/optimization/
Author: Google Inc
Author-email: [email protected]
License: Apache 2.0
Location: /home/user1/py_spool/lib/python3.6/site-packages
Requires: protobuf
Required-by:
(py_spool)
localhost ~/py_spool/lib/python3.6/site-packages/ortools/linear_solver
$ pip3 show ortools
localhost ~/py_spool/lib/python3.6/site-packages/ortools/linear_solver
$ python -m ortools.linear_solver.pywraplp
Traceback (most recent call last):
File "/home/user1/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "/home/user1/py_spool/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_pywraplp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user1/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 21, in <module>
_pywraplp = swig_import_helper()
File "/home/Vavaev/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 20, in swig_import_helper
return importlib.import_module('_pywraplp')
File "/home/user1/py_spool/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_pywraplp'
We do not support cygwin. Have you installed the visual studio
redistributable libraries ?
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le lun. 15 avr. 2019 Ã 13:19, st0ne-c0ld notifications@github.com a
écrit :
Hello all,
I have similar issue on cygwin. Module is there, but it can't import it
for some reason...$ pip3 show py3-ortools
Name: py3-ortools
Version: 5.1.4041
Summary: Google OR-Tools python libraries and modules
Home-page: https://developers.google.com/optimization/
Author: Google Inc
Author-email: [email protected]
License: Apache 2.0
Location: /home/user1/py_spool/lib/python3.6/site-packages
Requires: protobuf
Required-by:
(py_spool)
localhost ~/py_spool/lib/python3.6/site-packages/ortools/linear_solver
$ pip3 show ortools
localhost ~/py_spool/lib/python3.6/site-packages/ortools/linear_solver
$ python -m ortools.linear_solver.pywraplp
Traceback (most recent call last):
File "/home/user1/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "/home/user1/py_spool/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_pywraplp'During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user1/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 21, in
_pywraplp = swig_import_helper()
File "/home/Vavaev/py_spool/lib/python3.6/site-packages/ortools/linear_solver/pywraplp.py", line 20, in swig_import_helper
return importlib.import_module('_pywraplp')
File "/home/user1/py_spool/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named '_pywraplp'—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/541#issuecomment-483403080,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKj17a13FvaElxVHFz4KzvHmCBg4agL-ks5vhN7bgaJpZM4Q-MCe
.
Most helpful comment
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
choose 64 bit version.
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00
Le mar. 18 sept. 2018 à 18:36, Sayon notifications@github.com a écrit :