Skip to content

Two calls needed to pyimport a module in Julia, the first one crashes #681

@gvanuxem

Description

@gvanuxem

Affects: PythonCall

I installed sagelib using CondaPkg in Julia:
pkg> conda add sagelib

But importing it requires two calls for sage.all. Here is a Julia session:

┌──(greg㉿ellipse)-[~]
└─$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.7 (2025-09-08)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |

julia> using PythonCall

julia> sg=pyimport("sage.all")
ERROR: Python: TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Python stacktrace:
 [1] signal
   @ signal ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/signal.py:58
 [2] cysignals.pysignals.setsignal
   @ cysignals/pysignals.pyx:319
 [3] cysignals.pysignals.changesignal.__exit__
   @ cysignals/pysignals.pyx:373
 [4] init cysignals.pysignals
   @ cysignals/pysignals.pyx:488
 [5] init sage.interfaces.process (build/cythonized/sage/interfaces/process.c:7112)
   @ sage/interfaces/process.pyx:24
 [6] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/parallel/use_fork.py:22
 [7] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py:33
 [8] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/dynamics/arithmetic_dynamics/projective_ds.py:66
 [9] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/dynamics/arithmetic_dynamics/all.py:5
 [10] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/dynamics/all.py:25
 [11] <module>
   @ ~/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/all.py:127
Stacktrace:
 [1] pythrow()
   @ PythonCall.Core ~/.julia/packages/PythonCall/mkWc2/src/Core/err.jl:77
 [2] errcheck
   @ ~/.julia/packages/PythonCall/mkWc2/src/Core/err.jl:10 [inlined]
 [3] pyimport(m::String)
   @ PythonCall.Core ~/.julia/packages/PythonCall/mkWc2/src/Core/builtins.jl:1458
 [4] top-level scope
   @ REPL[2]:1

julia> sg=pyimport("sage.all")
Python: <module 'sage.all' from '/home/greg/.julia/environments/v1.11/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/sage/all.py'>

julia> sg.factor(sg.ZZ(376655555555555555554444444444443332346777712))
Python: 2^4 * 53 * 163 * 12391 * 219914853701821004027468433435262943

julia> sg.log(2.3)
Python: 0.832909122935104

Kali Linux on WSL
PythonCall v0.9.28
CondaPkg v0.2.33
Python version:
Python: '3.12.11 | packaged by conda-forge | (main, Jun 4 2025, 15:10:57) [GCC 13.3.0]'
sagelib v10.7

I wonder what happens here since in pure Python that works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions