pyjulia: PyJulia does not work with Julia 1.0 & 0.7 with Python installed via Conda/Ubuntu/(what else?)
I’m writing down the issue so that it is easy to find by the users.
At the moment, for PyJulia to load Julia >= 0.7, two conditions have to be met:
-
Python interpreter configured for PyCall.jl and Python interpreter used to import PyJulia have to use identical
libpython(once #190 is merged) <strike>have exactly identical paths</strike>. -
The Python interpreter have to be dynamically linked (which is usually the case in Windows and macOS according to this comment)
To check if condition 2 is the case, run:
$ ldd /usr/bin/python | grep libpython
libpython3.7m.so.1.0 => /usr/lib/libpython3.7m.so.1.0 (0x00007f17c12c4000)
where /usr/bin/python is the appropriate Python interpreter.
If it does not print anything, you can’t use PyJulia with this Python interpreter.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 8
- Comments: 36 (20 by maintainers)
This problem is not going to go away, Debian is not going to change it and lots and lots of people are going to try this as debian distros are the most popular (though I prefer Arch I still have to use them often myself). My first question is how other languages solve this problem. We can’t be the first people ever to want to use a dynamically linked Python executable. It would be good to see how Scala and Java solve this, though I haven’t started looking yet.
I think at a minimum what we need is a very clear set of the simplest possible steps that one would take to get
pyjuliarunning on debian in a very visible location right in the packages readme or documentation. Thanks to @tkf to taking the first steps to this with his pyenv setup, I’m going to try it myself when I get a chance.I think there are three ways to use Python with Julia 1.0 on Ubuntu/Debian/etc. at the moment:
IPython.jl/src/core.jl.I think I know how to fix it #173. But likely not in next weeks. I can’t grant anything 😃 If I were to do it I want to do it after dropping Julia 0.6 (which requires PyJulia to be released soon).
I merged a workaround for statically linked Python #200. Basically, you “just” need to run
python-jl script.py(notice the-jlsuffix) instead ofpython script.pyif you use Debian or conda. You can try it by:Or you can switch to Arch Linux 😆
It uses
--enable-shared: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/python&id=68e188a1f975dcc6798072bcda4ef35abfe162ed#n57What’s the status of this issue? I am trying to run PyJulia in Ubuntu 22 but python is statically linked.
It works in Arch Linux 😃
IIRC, the official
pythondocker works. It’s a bit old, but here is an example for setting up PyJulia in Docker: https://github.com/tkf/docker-pyjuliaAlso, just FYI, I started working on compile-time preference integration for PyCall https://github.com/JuliaPy/PyCall.jl/pull/835. If it works as I expected, PyJulia should just work without any hacks in Julia 1.6 and above. Obviously, there are still some unknowns as I haven’t finished implementing all. So, let’s see 😉
It’s a bit strange. 3.7.0 from conda-forge is statically linked:
But
conda-forge::python=3.6is dynamically linked.Yep, README is the only blocker before the release ATM.
@tkf ,thanks for your awesome work. The new package works on Ubuntu 16.04 with anaconda. It really helps.
There are some minor suggestions (or some misunderstanding of me).
third-party packages need to be re-compiled/re-installed
for test purpose, I test
from julia import NPZ, whileNPZis already added in original julia environment. But it failed.and the following code works:
It seems that pyjulia and julia of system is using different package cache? I think re-install packages is not a problem and it might be a valuable feature. I only suggest add some doc for this
convenient broadcast call
broadcast is commonly used in julia, but
Main.abs.([1,2,3])is aSyntaxErrorin python. inREADME.mdof pyjulia, there iswhich seems that pyjulia will not expose broadcast method to python level. I’m not sure if I am right, but if it is true, I’m thinking is it possible to adding some special syntax like
Main.abs.broadcast([1,2,3])or in shortMain.abs.b([1,2,3])(although may introduce some confusing tosum_bfor python versionsum!).InterruptException()handlingWhen I press
ctrl-Cin python REPL, there would be a small problem. If I’m using a pure python REPL, it should work like thisBut in a python REPL which loaded julia, it would work like this:
and nothing happens, after that if I enter next command
It seems the
InterruptExceptionis send to julia in one delayed statement?