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
PyCall.jl setting incorrect libpython on Julia 1.9 #522
Comments
What environment variables are being used? Unless you are using this activate script from the conda-forge julia-feedstock Conda.jl will have no idea where to find Python and will default to creating its own conda based install.
|
I'm not using conda at all. This is a homebrew-installed version of Python running in a virtualenv. In other words: > ls -lath $(which python3.10)
lrwxr-xr-x 1 mcranmer staff 44B Nov 8 11:07 /Users/mcranmer/venvs/main/bin/python3.10 -> /opt/homebrew/opt/python@3.10/bin/python3.10 |
One the following is needed:
|
I should emphasize that the exact same workflow with the exact same python environment works on Julia 1.8.5; it's only Julia 1.9.0 that generates this error. When I check the env: |
Weird. The contents of For Julia 1.9.0: > cat ~/.julia/prefs/PyCall
Conda and for Julia 1.8.5: > cat ~/.julia/prefs/PyCall
/Users/mcranmer/venvs/main/bin/python Again, this is the exact same Python environment and workflow. The entire |
Try adding https://github.com/JuliaPy/Conda.jl first and see if you can detect any differences. Step through PyCall.jl's deps.jl and see if you can identify the difference. |
FYI the output of py = get(ENV, "PYTHON", isfile(prefsfile) ? readchomp(prefsfile) :
(Sys.isunix() && !Sys.isapple()) ?
whichfirst("python3", "python") : "Conda") will return |
Interesting. When I build But on 1.9.0, PyJulia can't save it for whatever reason. |
I'm guessing that at some point there was an issue on macOS with it finding a system python. Keep working through the file. Something else must differ by the time it gets to line 114. |
I don't see any differences if I just run in Julia though. They (1.8.5 and 1.9.0) both fail to find the system Python. Somehow by running it through PyJulia, it succeeds in finding it; maybe some env variable being passed from PyJulia? But this stops being true on 1.9.0. |
Hmm, something has gone wrong here then: Lines 55 to 134 in 1e3de7b
|
Julia 1.8.5: install_cmd=['julia', '--startup-file=no', '--color=yes', '/Users/mcranmer/venvs/main/lib/python3.10/site-packages/julia-0.6.0-py3.10.egg/julia/install.jl', '--', 'install', '/Users/mcranmer/venvs/main/bin/python', '/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/Python'] 1.9.0: install_cmd=['julia', '--startup-file=no', '--color=yes', '/Users/mcranmer/venvs/main/lib/python3.10/site-packages/julia-0.6.0-py3.10.egg/julia/install.jl', '--', 'install', '/Users/mcranmer/venvs/main/bin/python', '/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/Python'] so the correct paths are being passed to |
Alright well that is a really nasty bug. Here's the problem: Line 1 in 1e3de7b
The behavior of this line changed from Julia 1.8 to 1.9. Here's the contents of
And here's the contents
meaning that the following variables were loaded:
i.e., it looks like |
It looks like this change was made to Julia here: JuliaLang/julia#45335 |
So the issue is in install.jl? |
I wouldn't call it an issue per se, it's more a breaking change in 1.9 in how Julia parses CLI arguments. A quick fix to the first line of -OP, python, libpython = ARGS
+OP, python, libpython = if VERSION < v"1.9.0"
+ ARGS
+else
+ ARGS[2:end]
+end |
* Correct CLI parsing for Julia 1.9 to fix #522 * Bump min Julia version to 1.4
I can't seem to get PyJulia working on Julia 1.9 (beta 4), although it works fine on 1.8.5. It seems to be some issue with the Python interpreter and libpython set by PyCall.jl. It could be interference from Conda.jl's installed copy of Python and libpython?
First, I set up a completely fresh Julia install with juliaup (note that this code will delete your
~/.julia
folder, only savingstartup.jl
):Then, I run:
python -c 'import julia; julia.install()'
Which succeeds. However, when I try to start Julia via PyJulia:
python -c 'from julia import Main'
despite the exact same set of environment variables as used in the `install`, this fails:
In particular, the Python interpreter and libpython seem to be set incorrectly:
I'm assuming these new
python
andlibpython
are packaged by thePyCall.jl
install. But I think ideally we would want them to be set by the user from their Python/libpython, for compatibility with Python libraries, right?I can run this entire workflow with
juliaup add 1.8 && juliaup default 1.8
instead, and it works fine.cc @mkitti @ngam @stevengj @marius311
edit: I should mention I'm not using conda at all. This is a homebrew-installed version of Python running in a virtualenv.
The text was updated successfully, but these errors were encountered: