Skip to content

Commit c442738

Browse files
Nisha ChandramoorthyNisha Chandramoorthy
andauthored
Add a more helpful error message when precompiling fails due to Python build change (#778)
* Add a more helpful error message when libpython is not found * remove pointer to nothing * Add additional if in case err does not have msg field * Change tabs to spaces * remove error message when object is not an errorException. * remove loading library twice Co-authored-by: Nisha Chandramoorthy <nishac92@gmail.com>
1 parent 8ee95bd commit c442738

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/startup.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ if !symbols_present
4444
isfile(depfile) || error("PyCall not properly installed. Please run Pkg.build(\"PyCall\")")
4545
include(depfile) # generated by Pkg.build("PyCall")
4646
# Only to be used at top-level - pointer will be invalid after reload
47-
libpy_handle = Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
47+
libpy_handle = try
48+
Libdl.dlopen(libpython, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
49+
catch err
50+
if err isa ErrorException
51+
error(err.msg, ". Please run `Pkg.build(\"PyCall\")` if your Python build has changed")
52+
else
53+
rethrow(err)
54+
end
55+
end
4856
# need SetPythonHome to avoid warning, #299
4957
Py_SetPythonHome(libpy_handle, pyversion_build, PYTHONHOME)
5058
else

0 commit comments

Comments
 (0)