Closed
Description
I'm on Red Hat Enterprise Linux 8.6, running Python 3.9.7. I haven't installed Julia, but juliapkg appears to download and install Julia 1.8.4 just fine. I've created and activated a virtual environment, then installed matplotlib and juliacall:
$ virtualenv -p `which python3.9` venv
$ source ./venv/bin/activate
$ pip install matplotlib juliacall
In my working directory I have one Julia file:
$ cat Foo.jl
struct Foo end
$
and two Python files. The first Python file includes the Foo.jl
file:
$ cat foo.py
import os
# Create a new Julia module that will hold all the Julia code imported into this Python module.
import juliacall; jl = juliacall.newmodule("FooModule")
# Get the directory this file is in, then include the `Foo.jl` Julia source code.
d = os.path.dirname(os.path.abspath(__file__))
jl.include(os.path.join(d, "Foo.jl"))
Foo = jl.Foo
$
And the second one imports the first foo.py
file:
$ cat run.py
import matplotlib
from foo import Foo
$
When I run the run.py
file, I get this error:
$ python run.py
ERROR: `ccall` requires the compilerTraceback (most recent call last):
File "/home/dingraha/projects/pythoncall_import_error/run.py", line 2, in <module>
from foo import Foo
File "/home/dingraha/projects/pythoncall_import_error/foo.py", line 4, in <module>
import juliacall; jl = juliacall.newmodule("FooModule")
File "/home/dingraha/projects/pythoncall_import_error/venv/lib/python3.9/site-packages/juliacall/__init__.py", line 218, in <module>
init()
File "/home/dingraha/projects/pythoncall_import_error/venv/lib/python3.9/site-packages/juliacall/__init__.py", line 214, in init
raise Exception('PythonCall.jl did not start properly')
Exception: PythonCall.jl did not start properly
$
Now, if I switch the order of the two import
lines in run.py
, there's no error. Also if I import juliacall
first, i.e.:
$ cat run-no_error.py
import juliacall
import matplotlib
from foo import Foo
$
the error goes away.
Any ideas?
Metadata
Metadata
Assignees
Labels
No labels