Skip to content

Julia 1.11 prevents assigning objects to Main #582

Closed
@MilesCranmer

Description

@MilesCranmer

It looks like this syntax is no longer working on Julia 1.11:

from juliacall import Main as jl

jl.x = 1

On 1.10 of Julia this works, but on 1.11, this raises the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import juliapkg as jp; jp.require_julia("~1.11"); from juliacall import Main as jl; jl.x = 1
                                                                                        ^^^^
  File "/Users/mcranmer/PermaDocuments/PythonCall.jl/src/JlWrap/any.jl", line 254, in __setattr__
    self._jl_callmethod($(pyjl_methodnum(pyjlany_setattr)), k, v)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: Julia: Global Main.x does not exist and cannot be assigned. Declare it using `global` before attempting assignment.

I also verified this error did not depend on Python (3.10 through 3.13 all give the same error).

To quickly verify this:

# 1.10
python -c 'import juliapkg as jp; jp.require_julia("~1.10"); from juliacall import Main as jl; jl.x = 1'
# (Exits fine)

# 1.11
python -c 'import juliapkg as jp; jp.require_julia("~1.11"); from juliacall import Main as jl; jl.x = 1'
# Throws an error

cc @cjdoris

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions