Skip to content
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

Fail with a helpful message if separate cache is not supported #186

Merged
merged 5 commits into from
Sep 10, 2018

Conversation

tkf
Copy link
Member

@tkf tkf commented Aug 18, 2018

It needs some discussion. Also, #183 has to be merged first.

With this PR, user will see error message like this which saves their time for googling the issues.

RuntimeError: It seems your Julia and PyJulia setup are not supported.

Julia interpreter:
    /home/takafumi/bin/julia-1.0.0
Python interpreter used by PyCall.jl:
    /home/takafumi/miniconda3/bin/python
Python interpreter used to import PyJulia.
    /usr/bin/python

In Julia >= 0.7, above two paths to the Python interpreters have to match
exactly in order for PyJulia to work.  To configure PyCall.jl to use Python
interpreter "/usr/bin/python",
run the following commands in the Julia interpreter:

    ENV["PYTHON"] = "/usr/bin/python"
    using Pkg
    Pkg.build("PyCall")

For more information, see:
    https://github.com/JuliaPy/pyjulia
    https://github.com/JuliaPy/PyCall.jl

I'm not 100% sure we want this. We should probably be better just support it. Supporting it via DEPOT_PATH may not be so bad (#173).

ref: #185

@mprogram
Copy link

(related to #185):

In the present case, it is a bit confusing as those two values are identical:

# python3
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia; julia.Julia(debug=True)

┌ Warning: `Pkg.dir(pkgname, paths...)` is deprecated; instead, do `import PyCall; joinpath(dirname(pathof(PyCall)), "..", paths...)`.
└ @ Pkg.API /build/julia-gZj_Ru/julia-0.7.0/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:454
pyprogramname = /usr/bin/python3
sys.executable = /usr/bin/python3
exe_differs = False
JULIA_HOME = /usr/bin,  libjulia_path = /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.0.7
calling jl_init_with_image(b'/usr/lib/python3/dist-packages/julia/fake-julia', /usr/lib/x86_64-linux-gnu/julia/sys.so)
seems to work...
exception occured? None
exception occured? None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/julia/core.py", line 646, in __init__
    self.__julia = Julia(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/julia/core.py", line 492, in __init__
    raise_separate_cache_error(runtime, depsjlexe)
  File "/usr/lib/python3/dist-packages/julia/core.py", line 320, in raise_separate_cache_error
    raise RuntimeError(message)
RuntimeError: It seems your Julia and PyJulia setup are not supported.

Julia interpreter:
    julia
Python interpreter used by PyCall.jl:
    /usr/bin/python3
Python interpreter used to import PyJulia.
    /usr/bin/python3

In Julia >= 0.7, above two paths to the Python interpreters have to match
exactly in order for PyJulia to work.  To configure PyCall.jl to use Python
interpreter "/usr/bin/python3",
run the following commands in the Julia interpreter:

    ENV["PYTHON"] = "/usr/bin/python3"
    using Pkg
    Pkg.build("PyCall")

For more information, see:
    https://github.com/JuliaPy/pyjulia
    https://github.com/JuliaPy/PyCall.jl
# ldd $(which python3)
	linux-vdso.so.1 (0x00007ffed6dec000)
	libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f03eed27000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f03eeb08000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f03ee904000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f03ee701000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f03ee4cf000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f03ee2b2000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f03edf14000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f03edb23000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f03eef2e000)

@tkf
Copy link
Member Author

tkf commented Aug 19, 2018

Thanks a lot for trying it out! Yes, it has to detect if Python is statically linked or not and then prints the right message.

@stevengj
Copy link
Member

Needs a rebase.

@coveralls
Copy link

coveralls commented Sep 6, 2018

Pull Request Test Coverage Report for Build 478

  • 22 of 39 (56.41%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-1.09%) to 77.341%

Changes Missing Coverage Covered Lines Changed/Added Lines %
julia/core.py 22 39 56.41%
Files with Coverage Reduction New Missed Lines %
julia/core.py 1 81.87%
julia/find_libpython.py 2 79.83%
Totals Coverage Status
Change from base Build 469: -1.09%
Covered Lines: 413
Relevant Lines: 534

💛 - Coveralls

@tkf tkf changed the title WIP: Fail with a helpful message if separate cache is not supported Fail with a helpful message if separate cache is not supported Sep 6, 2018
This was referenced Sep 6, 2018
@tkf
Copy link
Member Author

tkf commented Sep 6, 2018

Rebased and added some more tests. I think it's good to go.

For incompatible libpython (but dynamically linked), it now prints:

$ python2 -c "from julia import Main"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "julia/core.py", line 172, in load_module
    JuliaMainModule(self, fullname))
  File "julia/core.py", line 77, in __init__
    self._julia = loader.julia
  File "julia/core.py", line 164, in julia
    self.__class__.julia = julia = Julia()
  File "julia/core.py", line 574, in __init__
    raise_separate_cache_error(runtime, jlinfo)
  File "julia/core.py", line 404, in raise_separate_cache_error
    raise RuntimeError(message)
RuntimeError: It seems your Julia and PyJulia setup are not supported.

Julia interpreter:
    julia
Python interpreter and libpython used by PyCall.jl:
    /home/takafumi/.virtualenvs/julia1.0/bin/python3
    /usr/lib/libpython3.7m.so.1.0
Python interpreter used to import PyJulia and its libpython.
    /usr/bin/python2
    /usr/lib/libpython2.7.so.1.0

In Julia >= 0.7, above two paths to `libpython` have to match exactly
in order for PyJulia to work.  To configure PyCall.jl to use Python
interpreter "/usr/bin/python2",
run the following commands in the Julia interpreter:

    ENV["PYTHON"] = "/usr/bin/python2"
    using Pkg
    Pkg.build("PyCall")

For more information, see:
    https://github.com/JuliaPy/pyjulia
    https://github.com/JuliaPy/PyCall.jl

When libpython is statically linked:

$ ~/miniconda3/bin/python -c "from julia import Main"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/home/takafumi/repos/watch/pyjulia/julia/core.py", line 172, in load_module
    JuliaMainModule(self, fullname))
  File "/home/takafumi/repos/watch/pyjulia/julia/core.py", line 77, in __init__
    self._julia = loader.julia
  File "/home/takafumi/repos/watch/pyjulia/julia/core.py", line 164, in julia
    self.__class__.julia = julia = Julia()
  File "/home/takafumi/repos/watch/pyjulia/julia/core.py", line 574, in __init__
    raise_separate_cache_error(runtime, jlinfo)
  File "/home/takafumi/repos/watch/pyjulia/julia/core.py", line 404, in raise_separate_cache_error
    raise RuntimeError(message)
RuntimeError: It seems your Julia and PyJulia setup are not supported.

Julia interpreter:
    julia
Python interpreter and libpython used by PyCall.jl:
    /home/takafumi/.virtualenvs/julia1.0/bin/python3
    /usr/lib/libpython3.7m.so.1.0
Python interpreter used to import PyJulia and its libpython.
    /home/takafumi/miniconda3/bin/python
    /home/takafumi/miniconda3/lib/libpython3.6m.so.1.0

Your Python interpreter "/home/takafumi/miniconda3/bin/python"
is statically linked to libpython.  Currently, PyJulia does not support
such Python interpreter.  For available workarounds, see:
    https://github.com/JuliaPy/pyjulia/issues/185

For more information, see:
    https://github.com/JuliaPy/pyjulia
    https://github.com/JuliaPy/PyCall.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants