SciML / diffeqpy

Solving differential equations in Python using DifferentialEquations.jl and the SciML Scientific Machine Learning organization
MIT License
531 stars 39 forks source link

Error when import the "de" from the "diffeqpy" #141

Closed HuynhTran0301 closed 4 months ago

HuynhTran0301 commented 4 months ago

Question❓

I tried to import the DifferentialEquations tools from the diffeqpy package following the instructions after installing the package as:

from diffeqpy import de

I got the error below:

File [C:\ProgramData\Anaconda3\lib\site-packages\diffeqpy\de.py:5](file:///C:/ProgramData/Anaconda3/lib/site-packages/diffeqpy/de.py#line=4)
      3 de, _, _ = load_julia_packages("DifferentialEquations", "ModelingToolkit", "PythonCall")
      4 from juliacall import Main
----> 5 de.jit = Main.seval("jit(x) = typeof(x).name.wrapper(ModelingToolkit.complete(ModelingToolkit.modelingtoolkitize(x)), x.u0, x.tspan, x.p)") # kinda hackey
      6 de.jit32 = Main.seval("jit(x) = typeof(x).name.wrapper(ModelingToolkit.complete(ModelingToolkit.modelingtoolkitize(x)), Float32.(x.u0), Float32.(x.tspan), Float32.(x.p))") # kinda hackey
      7 sys.modules[__name__] = de # mutate myself

File [~\.julia\packages\PythonCall\S5MOg\src\JlWrap\any.jl:219](http://localhost:8888/lab/tree/~/.julia/packages/PythonCall/S5MOg/src/JlWrap/any.jl#line=218), in __setattr__(self, k, v)
    217     else:
    218         return
--> 219     self._jl_callmethod($(pyjl_methodnum(pyjlany_setattr)), k, v)
    220 def __dir__(self):
    221     return ValueBase.__dir__(self) + self._jl_callmethod($(pyjl_methodnum(pyjlany_dir)))

AttributeError: Julia: cannot assign variables in other modules

In addition, it did not have a problem when I imported the ode. Please help me how to fix the error. Thank you for your time and consideration.

ChrisRackauckas commented 4 months ago

Closing as a repeat of https://github.com/SciML/diffeqpy/issues/135