pyjulia: PyJulia not working with Julia 1.6 and Python 3.9

This looks a lot like: https://github.com/JuliaPy/pyjulia/issues/425 . Apologies ahead of time if this is just adding noise.

I’m working on a Jupyter Docker Image, where we previously supported PyJulia. This was working with an older base image that used Julia 1.2 . We’re now updating to a newer jupyter image, which is pulling Julia 1.6, and PyJulia, has now started failing.

Here’s my code:

from julia.api import Julia
jl = Julia(compiled_modules=False, debug=True)

And here’s the output:

DEBUG (428) 
DEBUG (428) Debug-level logging is enabled for PyJulia.
DEBUG (428) PyJulia version: 0.5.6
DEBUG (428) 
DEBUG (428) pyprogramname = /opt/conda/bin/python3
DEBUG (428) sys.executable = /opt/conda/bin/python
DEBUG (428) bindir = /opt/julia-1.6.0/bin
DEBUG (428) libjulia_path = /opt/julia-1.6.0/bin/../lib/libjulia.so.1
DEBUG (428) py_libpython = None
DEBUG (428) jl_libpython = /opt/conda/lib/libpython3.9.so.1.0
DEBUG (428) is_compatible_python = False
DEBUG (428) compiled_modules = 'no'
DEBUG (428) argv_list = [b'/opt/conda/bin/python', b'--compiled-modules', b'no']
DEBUG (428) argc = c_int(3)
DEBUG (428) jl_parse_opts called
DEBUG (428) argc = c_int(0)
DEBUG (428) calling jl_init_with_image(/opt/julia-1.6.0/bin, /opt/julia-1.6.0/lib/julia/sys.so)
DEBUG (428) seems to work...
DEBUG (428) exception occured? 140585542159504
---------------------------------------------------------------------------
JuliaError                                Traceback (most recent call last)
<ipython-input-1-85ca7f15393c> in <module>
      5 
      6 from julia.api import Julia
----> 7 jl = Julia(compiled_modules=False, debug=True)

/opt/conda/lib/python3.9/site-packages/julia/core.py in __init__(self, init_julia, jl_init_path, runtime, jl_runtime_path, debug, **julia_options)
    501         # Currently, PyJulia assumes that `Main.PyCall` exsits.  Thus, we need
    502         # to import `PyCall` again here in case `init_julia=False` is passed:
--> 503         self._call(IMPORT_PYCALL)
    504         self._call(u"using .PyCall")
    505 

/opt/conda/lib/python3.9/site-packages/julia/core.py in _call(self, src)
    536         # logger.debug("_call(%s)", src)
    537         ans = self.api.jl_eval_string(src.encode('utf-8'))
--> 538         self.check_exception(src)
    539 
    540         return ans

/opt/conda/lib/python3.9/site-packages/julia/core.py in check_exception(self, src)
    585         else:
    586             exception = sprint(showerror, self._as_pyobj(res))
--> 587         raise JuliaError(u'Exception \'{}\' occurred while calling julia code:\n{}'
    588                          .format(exception, src))
    589 

JuliaError: Exception 'LoadError' occurred while calling julia code:
const PyCall = Base.require(Base.PkgId(Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0"), "PyCall"))

I’m working with Jupyter, with an image based on: https://github.com/jupyter/docker-stacks/blob/master/datascience-notebook/Dockerfile (but with PyCall also installed and precompiled via our Dockerfile).

If I run PyCall = Base.require(Base.PkgId(Base.UUID(“438e738f-606a-5dbb-bf0a-cddfbfd45ab0”), “PyCall”)) from the /opt/julia-1.6.0/bin/julia executable, it does work… so it appears PyCall is installed for that executable. I’m unsure how to get PyJulia to see the package - and I’m not sure if I’m missing something obvious.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 4
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I also see the issue with Julia 1.5.1 and python 3.9.

2021-07-29T14:18:54.2226731Z   File "/home/hafnium/miniconda3/lib/python3.9/site-packages/julia/core.py", line 680, in __init__
2021-07-29T14:18:54.2227274Z     self.__julia = Julia(*args, **kwargs)
2021-07-29T14:18:54.2228006Z   File "/home/hafnium/miniconda3/lib/python3.9/site-packages/julia/core.py", line 503, in __init__
2021-07-29T14:18:54.2228529Z     self._call(IMPORT_PYCALL)
2021-07-29T14:18:54.2229247Z   File "/home/hafnium/miniconda3/lib/python3.9/site-packages/julia/core.py", line 538, in _call
2021-07-29T14:18:54.2229768Z     self.check_exception(src)
2021-07-29T14:18:54.2230501Z   File "/home/hafnium/miniconda3/lib/python3.9/site-packages/julia/core.py", line 587, in check_exception
2021-07-29T14:18:54.2231377Z     raise JuliaError(u'Exception \'{}\' occurred while calling julia code:\n{}'
2021-07-29T14:18:54.2232132Z julia.core.JuliaError: Exception 'LoadError' occurred while calling julia code:
2021-07-29T14:18:54.2233270Z const PyCall = Base.require(Base.PkgId(Base.UUID("438e738f-606a-5dbb-bf0a-cddfbfd45ab0"), "PyCall"))

FYI, there’re now PyJulia 0.5.7 and PyCall 1.92.5 that solve a couple of recent issues.