question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PyJulia not working with Julia 1.6 and Python 3.9

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
mhangaardcommented, Jul 29, 2021

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"))
1reaction
tkfcommented, Oct 25, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting — PyJulia 0.6.0 documentation
If you are unsure if your python has this problem, you can quickly check it by: ... The easiest workaround is to pass...
Read more >
PyJulia not working with Julia 1.6 and Python 3.9 - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >
julia.install() fails on python import error - Stack Overflow
You were right that PyCall in Julia was not configured to the same Python as I use to call Julia. The problem was...
Read more >
julia - PyPI
Julia /Python bridge with IPython support. ... python3 -m pip install julia # install PyJulia ... # you may need `--user` after `install`...
Read more >
julia_download - Kaggle
We can use Julia through a Python kernel, but we have to install it, ... .com/julialang2/bin/linux/x64/1.6/julia-1.6.0-linux-x86_64.tar.gz ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found