JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.46k stars 187 forks source link

ReadOnlyMemoryError() Windows Only #880

Open Liberty009 opened 3 years ago

Liberty009 commented 3 years ago

Hi,

I'm trying to use Julia to interact with casadi via PyCall, as it seems to be the best way to use casadi, but I get a ReadOnlyMemoryError() when I try to create solvers. The test process below works fine on Linux but fails to on Windows.

using PyCall
c = pyimport("casadi")
x=c.SX.sym('x')
nlp = Dict('x' => x, 'f' => (x-1)^2)
solver = c.nlpsol('solver', 'ipopt', nlp) <- This line causes the error!
sol = solver(lbx=-10, ubx=10)

I get the error:

ERROR: ReadOnlyMemoryError()
Stacktrace:
 [1] macro expansion at C:\Users\USER\.julia\packages\PyCall\tqyST\src\exception.jl:95 [inlined]
 [2] #109 at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:43 [inlined]
 [3] disable_sigint at .\c.jl:446 [inlined]
 [4] __pycall! at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:42 [inlined]
 [5] _pycall!(::PyObject, ::PyObject, ::Tuple{String,String,Dict{String,PyObject}}, ::Int64, ::Ptr{Nothing}) at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:29
 [6] _pycall!(::PyObject, ::PyObject, ::Tuple{String,String,Dict{String,PyObject}}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:11
 [7] (::PyObject)(::String, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:86
 [8] (::PyObject)(::String, ::Vararg{Any,N} where N) at C:\Users\USER\.julia\packages\PyCall\tqyST\src\pyfncall.jl:86
 [9] top-level scope at REPL[5]:1

Thanks!