Closed MilesCranmer closed 8 months ago
It might be good to automatically reset ~/.julia/prefs/PyCall
whenever julia.install()
is called? What do you think @mkitti?
I think PySR should catch julia.tools.PyCallInstallError
and print out some PySR-relevant information. Especially the above debugging tips.
I think another couple of changes would simplify the install process for the user:
@v1.8
. Right now it seems like install PyCall.jl globally will just freeze the python path.Couldn't we just check for a mismatch between PyCall.python and whatever the current Python executable is? How do you find the latter?
I'm not sure, because the Python executable could have the same name. So ideally we would want to also store the version of Python and any other meta information that might affect things.
Also, a note to myself: should add unit tests for issues like #287 and #222. Would probably need to perform the test within a docker container with pyenv installed, and switch pyenv partway.
We need more diagnostics here.
Can you catch this error and do one of the following?
println(stderr, Base.active_project())
println(stderr, read(Base.active_project()), String))
manifest = joinpath(dirname(Base.active_project()), "Manifest.toml"))
if isfile(manifest)
println(stderr, read(manifest, String))
end
Somehow either Project.toml or Manifest.toml had been corrupted or the active environment is not what we think it is.
If there is something to delete, it might be the deps folder within thr package.
I'm trying to get a docker container that can consistently reproduce this.
FYI I've only seen the error when building via PyJulia; I'm not sure how to trigger it with PyCall directly.
My current attempt to generate this error. No error reported yet...
I wonder if somehow the latest PyCall has made this error go away.
One potential solution if I can end up producing the bug: make the PySR environment equal to pysr-{pysr_version}-jl-{julia_version}-py-{python_version}
. That way the user would be forced to re-install PySR whenever any of those versions changes.
Okay I have something to reliably generate an error. If you install PySR with a specific Python version, and then change the Python version, remove ~/.julia/environments/pysr-0.14.2
, and try to re-install PySR, you will get an error during precompilation due to a missing libpython file (it tries to load an older one):
There should definitely be a way we can automatically fix this, right? Is it prefs
we need to update?
I note that even doing julia -e 'using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
beforehand does not seem to save things. The python -m pysr install
still fails...
It seems like PyCall.jl is storing the libpython
version inside packages/PyCall/ilqDX/deps/deps.jl
:
const libpython = "/root/.pyenv/versions/3.9.2/lib/libpython3.9.so.1.0"
Maybe that's the issue? Perhaps a new package directory is not being created when the Python binary changes?
Run a Julia process that executes this before trying to connect Julia and Python.
using Pkg
Pkg.activate("pysr..."; shared=true)
ENV["PYTHON"] = "/path/to/python"
Pkg.build("PyCall")
That will force the following file to run again.
https://github.com/JuliaPy/PyCall.jl/blob/master/deps/build.jl
That's a good idea. Let me try that.
I implemented your suggestion in #363 so it automatically updates PyCall. Seems to work locally! I added a unittest too.
Okay I'm temporarily going to close this with #363 merged. Fingers crossed. I'll leave it pinned though.
Fixed by #535
tldr, delete the folders:
~/.julia/packages/PyCall
~/.julia/prefs/PyCall
~/.julia/environments/pysr-{your-pysr-version}
and re-run
python -m pysr install
.I am documenting this error because it has shown up a lot for people, and I want to document the solution.
The error is basically that after upgrading Python or Julia or both, and running PySR or re-installing PySR, you get the following error:
The solution to this is to delete your
~/.julia/packages/PyCall
folder. Then, simply re-runpython -m pysr install
.If this gives you further errors in building, you should also delete
~/.julia/prefs/PyCall
, and re-run the install step. For further issues, you could delete~/.julia/environments
folder (or more specifically, the folders~/.julia/environments/pysr-{version}
and~/.julia/environments/{julia_version}
, if you want to keep your other environments).This should fix the problem. This issue is basically that the old installed version of PyCall.jl is attached to a specific combination of Julia and Python. And, for whatever reason, re-running
julia.install()
doesn't update the built version of PyCall.jl.This is a temporary manual solution. In the future PySR should handle this automatically.