You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: CP-SAT tutorial example crashes on Windows with 9.10.4067 #4227
#4225 has been closed as solved. But the issue remains. The tutorial example is still crashing on windows with 9.10 + python3.11. Perhaps an error of compilation in python wheel on pypi ?
Make sure to:
Update visual studio
Create a blank venv
Pip install ortools
Run the samples. It works for me.
Le ven. 10 mai 2024, 16:56, nhuet ***@***.***> a écrit :
I do not have visual studio.
We need to install visual studio to make ortools work ? I never needed it for previous versions yet.
As i am using the wheel from PyPi, i was rather expecting that no c++ library was needed to make it work ?
My "ultimate" goal is to make ortools 9.10 work for me on github runners "windows-latest" because i have unit tests using ortools in my ci-cd workflow. If you know the command to update their redistributable libraries on it, i would greatly appreciate it.
Hey, I was having the same problem. Windows 11, python 3.12, ortools 9.10.4067.
For my future use I'll just use ortools 9.9 since that seems to work fine.
While I was trying to find a solution I also noticed a similar issue with another python example from the documentation:
fromortools.init.pythonimportinitfromortools.linear_solverimportpywraplpdefmain():
print("Google OR-Tools version:", init.OrToolsVersion.version_string())
# Create the linear solver with the GLOP backend.solver=pywraplp.Solver.CreateSolver("GLOP")
ifnotsolver:
print("Could not create solver GLOP")
return# Create the variables x and y.x_var=solver.NumVar(0, 1, "x")
y_var=solver.NumVar(0, 2, "y")
print("Number of variables =", solver.NumVariables())
infinity=solver.infinity()
# Create a linear constraint, x + y <= 2.constraint=solver.Constraint(-infinity, 2, "ct")
constraint.SetCoefficient(x_var, 1)
constraint.SetCoefficient(y_var, 1)
print("Number of constraints =", solver.NumConstraints())
# Create the objective function, 3 * x + y.objective=solver.Objective()
objective.SetCoefficient(x_var, 3)
objective.SetCoefficient(y_var, 1)
objective.SetMaximization()
print(f"Solving with {solver.SolverVersion()}")
result_status=solver.Solve()
print(f"Status: {result_status}")
ifresult_status!=pywraplp.Solver.OPTIMAL:
print("The problem does not have an optimal solution!")
ifresult_status==pywraplp.Solver.FEASIBLE:
print("A potentially suboptimal solution was found")
else:
print("The solver could not solve the problem.")
returnprint("Solution:")
print("Objective value =", objective.Value())
print("x =", x_var.solution_value())
print("y =", y_var.solution_value())
print("Advanced usage:")
print(f"Problem solved in {solver.wall_time():d} milliseconds")
print(f"Problem solved in {solver.iterations():d} iterations")
if__name__=="__main__":
init.CppBridge.init_logging("basic-example.py")
cpp_flags=init.CppFlags()
cpp_flags.stderrthreshold=Truecpp_flags.log_prefix=Falseinit.CppBridge.set_flags(cpp_flags)
main()
In this example the line init.CppBridge.init_logging("basic-example.py")
never finishes and the program crashes silently.
The code works fine for ortools 9.9 with no other changes so it seems to me both these problems are related.
I did try to fix the problem with visual studio installer but this did not work for me.
What exactly are the requirements of visual studio for ortools?
Can you update the visual studio redistributable libraries.
Many users reported success doing so.
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le mer. 12 juin 2024 à 10:23, RobinParmentier ***@***.***> a
écrit :
Hey, I was having the same problem. Windows 11, python 3.12, ortools
9.10.4067.
For my future use I'll just use ortools 9.9 since that seems to work fine.
While I was trying to find a solution I also noticed a similar issue with
another python example from the documentation:
from ortools.init.python import init
from ortools.linear_solver import pywraplp
def main():
print("Google OR-Tools version:", init.OrToolsVersion.version_string())
# Create the linear solver with the GLOP backend.
solver = pywraplp.Solver.CreateSolver("GLOP")
if not solver:
print("Could not create solver GLOP")
return
# Create the variables x and y.
x_var = solver.NumVar(0, 1, "x")
y_var = solver.NumVar(0, 2, "y")
print("Number of variables =", solver.NumVariables())
infinity = solver.infinity()
# Create a linear constraint, x + y <= 2.
constraint = solver.Constraint(-infinity, 2, "ct")
constraint.SetCoefficient(x_var, 1)
constraint.SetCoefficient(y_var, 1)
print("Number of constraints =", solver.NumConstraints())
# Create the objective function, 3 * x + y.
objective = solver.Objective()
objective.SetCoefficient(x_var, 3)
objective.SetCoefficient(y_var, 1)
objective.SetMaximization()
print(f"Solving with {solver.SolverVersion()}")
result_status = solver.Solve()
print(f"Status: {result_status}")
if result_status != pywraplp.Solver.OPTIMAL:
print("The problem does not have an optimal solution!")
if result_status == pywraplp.Solver.FEASIBLE:
print("A potentially suboptimal solution was found")
else:
print("The solver could not solve the problem.")
return
print("Solution:")
print("Objective value =", objective.Value())
print("x =", x_var.solution_value())
print("y =", y_var.solution_value())
print("Advanced usage:")
print(f"Problem solved in {solver.wall_time():d} milliseconds")
print(f"Problem solved in {solver.iterations():d} iterations")
if __name__ == "__main__":
init.CppBridge.init_logging("basic-example.py")
cpp_flags = init.CppFlags()
cpp_flags.stderrthreshold = True
cpp_flags.log_prefix = False
init.CppBridge.set_flags(cpp_flags)
main()
In this example the line
init.CppBridge.init_logging("basic-example.py")
never finishes and the program crashes silently.
The code works fine for ortools 9.9 with no other changes so it seems to
me both these problems are related.
I did try to fix the problem with visual studio installer but this did not
work for me.
What exactly are the requirements of visual studio for ortools?
—
Reply to this email directly, view it on GitHub
<#4227 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3J3GIN5BIZWNPAOAV3ZHB7XPAVCNFSM6AAAAABHQOQM3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTGU2TKNJWGI>
.
You are receiving this because you were assigned.Message ID:
<google/or-tools/issues/4227/2163555562 ***@***.***>
Same for me, the solver crashes even though I have the latest vcredist: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810.
Env:
OS: win 11 Entreprise
Code: jdk21
FYI, I still did not succeed in making it work (and actually stopped trying, simply freezing for now ortools version). And github windows runner have recently upgraded their Microsoft Visual C++ 2015-2022 Redistributable and the example still crashes on it with ortools 9.10.
Activity
lperron commentedon May 10, 2024
most likely duplicate of:
nhuet commentedon May 10, 2024
#4225 has been closed as solved. But the issue remains. The tutorial example is still crashing on windows with 9.10 + python3.11. Perhaps an error of compilation in python wheel on pypi ?
nhuet commentedon May 10, 2024
With both python 3.11 and 3.12 + ortools 9.10.4067 + Windows 11 Pro, i got
(And the computation succeeds with ortools 9.9.3963)
More precisely, the python versions i tried: python 3.11.0 and 3.12.2
lperron commentedon May 10, 2024
nhuet commentedon May 10, 2024
I do not have visual studio.
We need to install visual studio to make ortools work ? I never needed it for previous versions yet.
As i am using the wheel from PyPi, i was rather expecting that no c++ library was needed to make it work ?
lperron commentedon May 10, 2024
nhuet commentedon May 10, 2024
As I said, the previous release of ortools worked fine for me without installing anything. But indeed i think i have the redistributable libraries preinstalled. I tried to update them using the link https://aka.ms/vs/17/release/vc_redist.x64.exe found on https://learn.microsoft.com/fr-fr/cpp/windows/latest-supported-vc-redist?view=msvc-170, but it changed nothing for me.
My "ultimate" goal is to make ortools 9.10 work for me on github runners "windows-latest" because i have unit tests using ortools in my ci-cd workflow. If you know the command to update their redistributable libraries on it, i would greatly appreciate it.
lperron commentedon May 10, 2024
it works fine: https://github.com/google/or-tools/actions/runs/8998718133
Oops: it does not test the right thing.
Freeze ortools for windows tests
Freeze ortools for windows tests
lperron commentedon May 16, 2024
Note this was solved on S.O.L: https://stackoverflow.com/questions/78489444/google-ortools-sat-cpsolver-solve-causes-accessviolationexception/78489630#78489630
jeremydover commentedon May 20, 2024
I experienced this error on upgrading to ortools version 9.10, and upgrading the Virtual Studio C++ redistributable at the link above (https://aka.ms/vs/17/release/vc_redist.x64.exe) fixed the problem for me.
Freeze ortools for windows tests
lperron commentedon Jun 3, 2024
Most likely this is fixed.
RobinParmentier commentedon Jun 12, 2024
Hey, I was having the same problem. Windows 11, python 3.12, ortools 9.10.4067.
For my future use I'll just use ortools 9.9 since that seems to work fine.
While I was trying to find a solution I also noticed a similar issue with another python example from the documentation:
In this example the line
init.CppBridge.init_logging("basic-example.py")never finishes and the program crashes silently.
The code works fine for ortools 9.9 with no other changes so it seems to me both these problems are related.
I did try to fix the problem with visual studio installer but this did not work for me.
What exactly are the requirements of visual studio for ortools?
lperron commentedon Jun 12, 2024
RobinParmentier commentedon Jun 13, 2024
I tried using the link that was posted here earlier (https://aka.ms/vs/17/release/vc_redist.x64.exe) but this didn't work for me.
walelo9787 commentedon Jun 18, 2024
Same for me, the solver crashes even though I have the latest vcredist: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810.
Env:
OS: win 11 Entreprise
Code: jdk21
nhuet commentedon Jun 20, 2024
FYI, I still did not succeed in making it work (and actually stopped trying, simply freezing for now ortools version). And github windows runner have recently upgraded their Microsoft Visual C++ 2015-2022 Redistributable and the example still crashes on it with ortools 9.10.