-
Notifications
You must be signed in to change notification settings - Fork 61
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
Error when importing matplotlib and JuliaCall from Python #255
Comments
Actually, an even simpler MWE is to just import matplotlib and then juliacall from one file:
Here is what I have installed in the virtual environment:
|
Thanks for the detailed report. That's a very odd error message that I don't understand at all, and Googling for "Julia compiler traceback" returns nothing. Looks like a Julia internal thing to investigate. Julia 1.8.5 is released, you could upgrade ( |
Yep, Julia 1.8.5 does seem to fix the error. I'm going to try to test this a bit more, then I'll close the issue. Thanks for the help! |
OK, I spoke too soon. I'm testing this with two approaches to using Python:
I've tried Julia 1.8.4 and 1.8.5. If I run this script: import matplotlib
import juliacall with a Python from a conda environment and either Julia 1.8.4 or 1.8.5, everything is fine. I know that most people discourage using the system Python for code development, so maybe this is a non-issue? |
Hmm. Well the error arises in this line of the Julia source code: https://github.com/JuliaLang/julia/blob/ba69cbaa8e04657b6f4dceced76696575053f28b/src/interpreter.c#L338 As the error message says, it's because the Julia compiler is not available for some reason - which seems weird. I don't know what can cause that to occur. My best guess is that your system Python has been built in a non-standard way that prevents Julia from linking to its compiler. Maybe it's statically linked? Maybe it's linked to an old version of LLVM? I can only guess. What's the output of As you say, the system Python is typically only there to support the system. You're generally expected to install Python yourself if you actually want to use it. |
Here's the output of
And this is what I get for
I don't see any significant differences there. A few other data points: I don't see this bug when running tests on GitHub Actions Ubuntu machines using this in the YAML file:
I also don't run into this bug when using the system Python on Arch Linux. Another hint: If I set
So the problem appears to have something to do with I wonder if the problem is related to how old the C/C++-related stuff is on Red Hat? On Red Hat 8.6, I have Not sure how to debug this further. Any ideas? |
Is it possible to inspect which libraries have been linked after matplotlib is loaded? Your theory sounds totally plausible - if you use PythonCall from Julia, we ensure the Conda environment is compatible with the version of libstdc++ which Julia has installed, otherwise nasty errors occur. Maybe something similar happens using JuliaCall from Python - e.g. matplotlib could be loading a too-old version of libstdc++. |
Oh, good idea!
Yes, that appears to be the problem! Turns out you can see what shared libraries are being loaded by setting
I can run
Then if I look through
Looks like the script tries to load the system libstdc++ at But for
The script fails, and I see the usual error in
And then later:
So, mystery solved. Looks like a mention of this would fit in well with the FAQs in the docs. I will submit a PR. Thanks! |
Closing since I think the only fix is to document the issue, which is done now (thank you). |
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:
In my working directory I have one Julia file:
and two Python files. The first Python file includes the
Foo.jl
file:And the second one imports the first
foo.py
file:When I run the
run.py
file, I get this error:Now, if I switch the order of the two
import
lines inrun.py
, there's no error. Also if I importjuliacall
first, i.e.:the error goes away.
Any ideas?
The text was updated successfully, but these errors were encountered: