Update: I think this problem may not be solved unless the absolute path used in
PyCall
was fixed
Hi, I am getting this error when I run a compiled Julia app on another win10 machine. I found an almost same problem issued 4 days ago here. My system is win10, the error message is as follows.
fatal: error thrown and no exception handler available.
InitError(mod=:PyCall, error=ErrorException("could not load library "C:\Users\JerryYang\.julia\conda\3\python39.dll"
The specified module could not be found. "))
jl_errorf at /cygdrive/c/buildbot/worker/package_win64/build/src\rtutils.c:77
jl_load_dynamic_library at /cygdrive/c/buildbot/worker/package_win64/build/src\dlload.c:284
#dlopen#3 at .\libdl.jl:117
dlopen at .\libdl.jl:117 [inlined]
__init__ at C:\Users\JerryYang\.julia\packages\PyCall\7a7w0\src\pyinit.jl:149
jfptr___init___34563.clone_1 at G:\DemoExecutable\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_module_run_initializer at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:73
_finish_julia_init at /cygdrive/c/buildbot/worker/package_win64/build/src\init.c:796
jl_init_with_image at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:74 [inlined]
jl_init_with_image at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:63 [inlined]
jl_init at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:90
.text at G:\DemoExecutable\bin\Demo.exe (unknown line)
__tmainCRTStartup at G:\DemoExecutable\bin\Demo.exe (unknown line)
.l_start at G:\DemoExecutable\bin\Demo.exe (unknown line)
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
It seems that this program is searching an absolute directory on my machine: "C:\Users\JerryYang\.julia\conda\3\python39.dll"
. I thought for a build binary file, there should be no files to be needed under directory of machine where it was compiled, and the fixed absolute path seems really strange.
I guess this problem was caused by PyCall
’s non-relocatability. Other packages don’t seem to have this problem. The compilation process went well, and there is no problem when it was running on my own machine.
D:\absolute\path>julia -q --project
julia> using PackageCompiler
julia> create_app("Demo","DemoExecutable")
PackageCompiler: bundled artifacts:
├── Bzip2_jll - 2.232 MiB
├── CRlibm_jll - 584.826 KiB
├── Cairo_jll - 13.579 MiB
├── EarCut_jll - 678.178 KiB
├── Expat_jll - 1.132 MiB
├── FFMPEG_jll - 27.893 MiB
├── Fontconfig_jll - 3.017 MiB
├── FreeType2_jll - 4.737 MiB
├── FriBidi_jll - 570.671 KiB
├── GLFW_jll - 711.095 KiB
├── GR_jll - 30.648 MiB
├── Gettext_jll - 19.930 MiB
├── Glib_jll - 20.546 MiB
├── Graphite2_jll - 696.780 KiB
├── HarfBuzz_jll - 6.257 MiB
├── Hwloc_jll - 9.260 MiB
├── JpegTurbo_jll - 4.951 MiB
├── LAME_jll - 1.398 MiB
├── LERC_jll - 758.367 KiB
├── LZO_jll - 1.084 MiB
├── Libffi_jll - 205.667 KiB
├── Libgcrypt_jll - 6.433 MiB
├── Libgpg_error_jll - 2.227 MiB
├── Libiconv_jll - 2.245 MiB
├── Libtiff_jll - 9.779 MiB
├── Ogg_jll - 693.400 KiB
├── OpenSSL_jll - 14.619 MiB
├── OpenSpecFun_jll - 798.680 KiB
├── Opus_jll - 3.208 MiB
├── PCRE_jll - 4.222 MiB
├── Pixman_jll - 5.945 MiB
├── Qt5Base_jll - 82.872 MiB
├── Rmath_jll - 453.627 KiB
├── Sundials_jll - 15.889 MiB
├── Wayland_protocols_jll - 465.663 KiB
├── XML2_jll - 7.444 MiB
├── XSLT_jll - 2.226 MiB
├── Zstd_jll - 3.936 MiB
├── libass_jll - 1.424 MiB
├── libfdk_aac_jll - 8.899 MiB
├── libpng_jll - 1.714 MiB
├── libvorbis_jll - 1.385 MiB
├── x264_jll - 5.880 MiB
└── x265_jll - 12.785 MiB
Total artifact file size: 346.257 MiB
✔ [02m:21s] PackageCompiler: compiling base system image (incremental=false)
Precompiling project...
240 dependencies successfully precompiled in 747 seconds
✔ [05m:58s] PackageCompiler: compiling incremental system image
julia>
The code looks like this:
module Demo
function julia_main()::Cint
len = length(ARGS)
if len == 0
println("An option is needed!")
println("Type --help or -h to see available options.")
else
if ARGS[1] == "--help" || ARGS[1] == "-h"
print("""Demo.exe <options>
-h, --help Print something
-1 Print something
-2 Print something
""")
elseif ARGS[1] == "-1"
println()
include("file1.jl")
elseif ARGS[1] == "-2"
println()
include("file2.jl")
else
println("Invalid option!")
end
end
return 0
end
if abspath(PROGRAM_FILE) == @__FILE__
julia_main()
end
end # module
file1.jl
and file2.jl
are added in the directory of Demo.exe
. I’m new to julia’s project structure and app compilation, using include()
here may not be a good way of doing this (and I also want to know about the proper way of directly running another julia file like a script rather than using
or import
), but it can work on my machine.