-
Notifications
You must be signed in to change notification settings - Fork 70
Errors when Python using juliacall and jl.evalfile to call a Julia package that then uses PythonCall #235
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
Comments
Yeah an MWE would be great thanks. |
MWE for me: On Windows 10, using Julia 1.8.2, PythonCall 0.9.9, and Python 3.9.13:
In
In
Then
FWIW, my Julia code was working just fine being called from Python until I tried to wrap it in a package to get some improved precompilation. Hope this helps! |
Hey, @cjdoris , I'm wondering if you have a hunch about where to start in this. I'm happy to take a crack at a PR if you're busy, but I'm at a loss on this. Don't mean to rush you if you've got other things on your plate right now, just want to help if I can! |
Sorry I've been on holiday then was ill. Will take a look in the next week or so. |
Sorry to hear that! Not a problem at all. Thanks for all you work! |
After coming back to the problem, I've found that making sure it finds a correct juliapkg.json file for the Python script seems to prevent the error. I'm investigating that further. |
@mrufsvold @cjdoris I am hitting this same error with a julia project that has I can circumvent this error by explicitly precompiling the julia project code beforehand, in a separate process outside of juliacall, at which point Any advice on how to start on this would be super helpful, I would like to contribute to this project as well. Thanks @cjdoris for creating such a handy tool! |
For anyone who comes across this issue, there is a pretty simple workaround, just put this before your import juliapkg
import subprocess
subprocess.call(
f"""{juliapkg.executable()} --project={juliapkg.project()} -e 'using MyProject' """,
# TODO get stdout/stderr to show up
shell=True,
) Will update when i figure out a clean way to display stdout/stderr |
Thanks for the hints everyone, I figured it out. It's now fixed and I've made a release. Upgrade to juliapkg 0.1.10 and juliacall 0.9.12 to try it out. I'm closing this issue now, but please comment if it's still not working for you. |
I upgraded to PythonCall.jl / juliacall 0.9.12 and everything works as hoped for. Thanks @cjdoris ! |
I'll provide more information later - I'm trying to create a MWE, but essentially it fails in init_pointers, saying that PyObject_Call cannot be found, if the julia code is called (via juliacall, with jl.evalfile).
If the same code is started directly from Julia (i.e. simply uses PythonCall), everything works as expected.
This was using various versions of Julia (1.7, 1.8), and various versions of Python (3.7, 3.8)
The text was updated successfully, but these errors were encountered: