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

Loading Julia packages (using) fails: (julia.core.JuliaError: Exception 'InitError: could not load library...') #553

Open
dorn-gerhard opened this issue Jan 18, 2024 · 2 comments

Comments

@dorn-gerhard
Copy link

I am using Julia 1.10, python 3.8 and the newest Pyjulia version on Windows.

when trying to import some Julia packages (e.g. Images.jl) an error occurs, trying to import again throws another error. Third import try solves the issue (see code below)
(running python-jl.exe solves the issue but would be nice, to get it running using pyhton.exe)

Maybe there is an issue in the order of loading subpackages?

any ideas how to circumvent the first two errors?

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> jl = julia.Julia()
>>> jl.eval("using Images")
C:\Users\gerharddorn\AppData\Local\Programs\Python\Python38\lib\site-packages\julia\core.py:715: FutureWarning: Accessing `Julia().<name>` to obtain Julia objects is deprecated.  Use `from julia import Main; Main.<name>` or `jl = Julia(); jl.eval('<name>')`.
  warnings.warn(
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gerharddorn\AppData\Local\Programs\Python\Python38\lib\site-packages\julia\core.py", line 633, in eval
    ans = self._call(src)
  File "C:\Users\gerharddorn\AppData\Local\Programs\Python\Python38\lib\site-packages\julia\core.py", line 561, in _call
    self.check_exception(src)
  File "C:\Users\gerharddorn\AppData\Local\Programs\Python\Python38\lib\site-packages\julia\core.py", line 615, in check_exception
    raise JuliaError(u'Exception \'{}\' occurred while calling julia code:\n{}'
julia.core.JuliaError: Exception 'InitError: could not load library "libamd.dll"
Das angegebene Modul wurde nicht gefunden. 
during initialization of module SuiteSparse_jll' occurred while calling julia code:
using Images
>>> jl.eval("using Images")
┌ Error: Error during initialization of module CHOLMOD
│   exception =
│    could not load library "libcholmod"
│    �E��☻
│    Stacktrace:
│      [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
│        @ Base.Libc.Libdl .\libdl.jl:117
│      [2] dlopen (repeats 2 times)
│        @ .\libdl.jl:116 [inlined]
│      [3] __init__()
│        @ SparseArrays.CHOLMOD C:\Users\gerharddorn\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\SparseArrays\src\solvers\cholmod.jl:181
│      [4] run_module_init(mod::Module, i::Int64)
│        @ Base .\loading.jl:1128
│      [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
│        @ Base .\loading.jl:1116
│      [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
│        @ Base .\loading.jl:1061
│      [7] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::String, sourcepath::String, depmods::Vector{Any})
│        @ Base .\loading.jl:1475
│      [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
│        @ Base .\loading.jl:1568
│      [9] _require(pkg::Base.PkgId, env::String)
│        @ Base .\loading.jl:1932
│     [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base .\loading.jl:1806
│     [11] #invoke_in_world#3
│        @ Base .\essentials.jl:921 [inlined]
│     [12] invoke_in_world
│        @ Base .\essentials.jl:918 [inlined]
│     [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base .\loading.jl:1797
│     [14] macro expansion
│        @ Base .\loading.jl:1784 [inlined]
│     [15] macro expansion
│        @ Base .\lock.jl:267 [inlined]
│     [16] __require(into::Module, mod::Symbol)
│        @ Base .\loading.jl:1747
│     [17] #invoke_in_world#3
│        @ Base .\essentials.jl:921 [inlined]
│     [18] invoke_in_world
│        @ Base .\essentials.jl:918 [inlined]
│     [19] require(into::Module, mod::Symbol)
│        @ Base .\loading.jl:1740
└ @ SparseArrays.CHOLMOD C:\Users\gerharddorn\.julia\juliaup\julia-1.10.0+0.x64.w64.mingw32\share\julia\stdlib\v1.10\SparseArrays\src\solvers\cholmod.jl:241
>>> jl.eval("using Images")
>>> jl.eval("RGB(1,0,0)") 
<PyCall.jlwrap RGB{N0f8}(1.0,0.0,0.0)>
@mkitti
Copy link
Member

mkitti commented Mar 14, 2024

I am perplexed by this as well. Where did you obtain Julia and Python from?

@dorn-gerhard
Copy link
Author

I use juliaup and pip

my workaround so far was^^

for k in range(3):
    try: 
        jl.include("file_with_using_packages.jl")
        print("import succeded - just wait ;)")
        break
    except:
        time.sleep(0.5)
        print("import failed - everything is okay 💖💗💓💖")    
    print("next line")

I also tested the newer juliacall and pythoncall packages - they work will just need a bit more work for setting paths and environments up and for working on the gpu you have to switch on signal handling if you want to be safe with garbage collection while multithreading:

a solution to this:
os.environ["PYTHON_JULIACALL_HANDLE_SIGNALS"]="yes"

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

No branches or pull requests

2 participants