Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing de #135

Closed
natasa-pavlov opened this issue Feb 1, 2024 · 9 comments
Closed

Error when importing de #135

natasa-pavlov opened this issue Feb 1, 2024 · 9 comments
Labels
question Further information is requested

Comments

@natasa-pavlov
Copy link

Question❓

I'm having issues when I run the line from diffeqpy import de in Python 3.9.6 and with Julia 1.8.3. installed.

I get the following error:

>>> from diffeqpy import de
  Activating project at `~/.julia/environments/diffeqpy`
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/natasa/Library/Python/3.9/lib/python/site-packages/diffeqpy/de.py", line 5, in <module>
    de.jit = Main.seval("jit(x) = typeof(x).name.wrapper(ModelingToolkit.modelingtoolkitize(x), x.u0, x.tspan, x.p)") # kinda hackey
  File "/Users/natasa/.julia/packages/PythonCall/wXfah/src/jlwrap/any.jl", line 204, in __setattr__
    self._jl_callmethod($(pyjl_methodnum(pyjlany_setattr)), k, v)
AttributeError: Julia: cannot assign variables in other modules

Any feedback will be much appreciated!

@natasa-pavlov natasa-pavlov added the question Further information is requested label Feb 1, 2024
@ChrisRackauckas
Copy link
Member

Are you sure you're on the latest versions of the packages?

@HuynhTran0301
Copy link

I have the same problem. I use Python 3.9.13, but I have several versions of Julia, ranging from 1.8.x to 1.10.x. I have installed the latest version of diffeqpy. When I implemented the ode it did not have the issue. How could I fix it?

@ChrisRackauckas
Copy link
Member

@LilithHafner can you look into this?

@LilithHafner
Copy link
Member

I'm having trouble reproducing this issue. I've tried on MacOS 13.6.3 on apple silicon with Julia 1.10.3 and python 3.9.13, using diffeqpy version 2.4.1 and juliacall version 0.9.20. (I've also tried on Asahi linux with a variety over versions).

Would either of you be willing to report more detailed reproduction instructions?

Some useful things to know would be

  • What python package manager you're using
  • The versions of all installed python packages (e.g. pip freeze)
  • The versions in the Julia project @diffeqpy (launch Julia, press ] to enter the Pkg prompt, enter activate @diffeqpy, enter st)
(@v1.10) pkg> activate @diffeqpy
  Activating project at `~/.julia/environments/diffeqpy`

(@diffeqpy) pkg> st
Status `~/.julia/environments/diffeqpy/Project.toml`
  [0c46a032] DifferentialEquations v7.13.0
  [961ee093] ModelingToolkit v9.15.0
  [6099a3de] PythonCall v0.9.20

I'll try to debug and fix this without reproducing it, but it would be much more effective if I can get the error to appear locally. Thanks!

@LilithHafner
Copy link
Member

LilithHafner commented May 28, 2024

I'm guessing that updating to Julia 1.9 or higher will fix this (see: JuliaLang/julia#54607)

I can also prepare a PR to this package that works around this behavior if @ChrisRackauckas would like us to continue supporting versions of Julia prior to 1.9.

I mistakenly assumed that @HuynhTran0301 reproduced this error using Julia 1.10; I will try to convince diffeqpy to use Julia 1.8 instead and see if I can reproduce the issue then.

@ChrisRackauckas
Copy link
Member

I mistakingly believed this was reproduced with Julia v1.10, but since it was demonstrated to actually only be v1.8 and below, I'm willing to say that doesn't need to be solved. The new v1.10 LTS will be coming out rather soon, so it won't even be easy for most people to find pre v1.10 versions. We're fine just supporting LTS and above.

@HuynhTran0301
Copy link

Thank you for the reply from @LilithHafner I have checked the package version as you suggested.
I run the diffeqpy on Python 3.9.13. with the version 2.4.1.
However, I am not sure about the Julia version. I have installed different versions of Julia from 1.8.5, 1.9.2, 1.9.4 and 1.9.10.
After running the code you provided I got the same information as follows:

Status `C:\Users\htran\.julia\environments\diffeqpy\Project.toml`
⌃ [0c46a032] DifferentialEquations v7.10.0
⌃ [961ee093] ModelingToolkit v8.70.0
  [6099a3de] PythonCall v0.9.20

How could I set up the specified version using Julia through PythonCall? As you mentioned the error may be happened for version 1.10 or 1.8.

@LilithHafner
Copy link
Member

@HuynhTran0301, you can run this to determine which version of Julia is running:

x@fedora:~$ python
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from juliacall import Main
>>> Main.seval("versioninfo()")
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (aarch64-linux-gnu)
  CPU: 8 × unknown
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, generic)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_PYTHONCALL_EXE = /usr/bin/python

How could I set up the specified version using Julia through PythonCall?

I don't know yet but see JuliaPy/PythonCall.jl#506

@HuynhTran0301
Copy link

@LilithHafner Thank you for your reply. Now I understand why I got the issue, the Julia API is run with Julia version 1.8.5. I am trying to change it to 1.9.x. I will update the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants