JuliaPy / JuliaPy/PythonCall.jl

Can't use PythonCall in Custom System Image

未关闭
#600 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Julia
星标
1.1k
派生
86
平均合并
1 天 22 小时
30 天内合并 PR
3

描述

**Affects:** PythonCall

**Describe the bug**
I'm trying to build a Julia system image that uses PythonCall.jl. I can build the system image, but when I try to launch Julia with it it crashes on initialisation.

As a MWE, I've set up a package [here](https://github.com/BenCurran98/CondaIssue.jl) that just uses PythonCall.jl. You can then run the following code to create a system image with this package:

```julia
using Pkg
Pkg.add(url = "https://github.com/BenCurran98/CondaIssue.jl")
Pkg.add("PackageCompiler.jl")
using PackageCompiler
create_sysimage(["CondaIssue"]; sysimage_path = "CondaSysImage.so")
```

This builds successfully, but when I run it I get the following error:
```
julia -JCondaSysImage.so --project=.
```

```julia
CondaPkg Found dependencies: /home/ben/.julia/packages/PythonCall/WMWY0/CondaPkg.toml
fatal: error thrown and no exception handler available.
InitError(mod=:C, error=MethodError(f=Base.Cmd, args=(Array{Nothing, 1}(dims=(1,), mem=Memory{Nothing}(1, 0x7183379f3380)[nothing]),), world=0x0000000000006869))
jl_method_error_bare at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/gf.c:2254
jl_method_error at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/gf.c:2272
jl_lookup_generic_ at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/gf.c:3106 [inlined]
ijl_apply_generic at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/gf.c:3121
jl_apply at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
do_call at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:126
eval_value at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:223
eval_stmt_value at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:174 [inlined]
eval_body at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:670
jl_fptr_interpret_call at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:760
#pixi#4 at /home/ben/.julia/packages/JLLWrappers/GfYNv/src/products/executable_generators.jl:81
jl_apply at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
do_call at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:126
eval_value at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:223
eval_stmt_value at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:174 [inlined]
eval_body at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:670
jl_fptr_interpret_call at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/interpreter.c:760
pixi at /home/ben/.julia/packages/JLLWrappers/GfYNv/src/products/executable_generators.jl:72
jl_apply at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_f__call_latest at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/builtins.c:875
#invokelatest#2 at ./essentials.jl:1055 [inlined]
invokelatest at ./essentials.jl:1052
unknown function (ip: 0x71833b906212)
#pixi_cmd#7 at /home/ben/.julia/packages/CondaPkg/pEObH/src/backend.jl:96
pixi_cmd at /home/ben/.julia/packages/CondaPkg/pEObH/src/backend.jl:93
#70 at /home/ben/.julia/packages/CondaPkg/pEObH/src/resolve.jl:916
cd at ./file.jl:112
unknown function (ip: 0x71833b97ccd6)
#resolve#64 at /home/ben/.julia/packages/CondaPkg/pEObH/src/resolve.jl:904
resolve at /home/ben/.julia/packages/CondaPkg/pEObH/src/resolve.jl:682
envdir at /home/ben/.julia/packages/CondaPkg/pEObH/src/env.jl:70
init_context at /home/ben/.julia/packages/PythonCall/WMWY0/src/C/context.jl:63
unknown function (ip: 0x71833b902cbf)
tojlinvoke103745 at /home/ben/Testing/Julia/CondaSysImage.so (unknown line)
j_init_context_102425 at /home/ben/Testing/Julia/CondaSysImage.so (unknown line)
__init__ at /home/ben/.julia/packages/PythonCall/WMWY0/src/C/C.jl:23
jfptr___init___102423 at /home/ben/Testing/Julia/CondaSysImage.so (unknown line)
jl_apply at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/julia.h:2157 [inlined]
jl_module_run_initializer at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/toplevel.c:76
_finish_julia_init at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/init.c:902
julia_init at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/init.c:843
jl_repl_entrypoint at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/src/jlapi.c:1053
main at /cache/build/builder-amdci5-5/julialang/julia-release-1-dot-11/cli/loader_exe.c:58
unknown function (ip: 0x71834382a1c9)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
```

I've seen similar issues with system images posted here, but they seem more related to the python path rather than this error which I can't identify the cause of. I would appreciate any help you can offer! Thanks :)

**Your system**
- Operating system: Ubuntu 24.04
- Julia version: 1.11.4
- PythonCall version: 0.9.24

```julia
julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 28 × 13th Gen Intel(R) Core(TM) i7-13850HX
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 16 default, 0 interactive, 8 GC (on 28 virtual cores)

julia> Pkg.status()
Project CondaIssue v0.1.0
Status `~/Testing/Julia/CondaIssue.jl/Project.toml`
[6099a3de] PythonCall v0.9.24

julia> CondaPkg.status()
CondaPkg Status /home/ben/Testing/Julia/CondaIssue.jl/CondaPkg.toml
Environment
/home/ben/Testing/Julia/CondaIssue.jl/.CondaPkg/.pixi/envs/default
Packages
numpy v2.1.0
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start by reproducing the failure with the provided PackageCompiler.create_sysimage command and inspect PythonCall's src/C/context.jl together with CondaPkg's src/backend.jl around the reported stack frames. Done means the generated system image launches without the initialization crash while retaining the reported PythonCall and CondaPkg setup.

由索引模型根据 Issue 内容生成。

评估

技术栈
julia, python
领域
backend, build-system
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。