-
Notifications
You must be signed in to change notification settings - Fork 101
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
PyJulia does not work with Julia 1.0 & 0.7 with Python installed via Conda/Ubuntu/(what else?) #185
Comments
This was very helpful; thank you, @tkf I must say I was very-very surprised by not finding Debian/Ubuntu packagers are the known strong advocates against linking things statically; but doing so in |
Yeah, I was surprised too. I thought it was just conda (in which static compilation maybe makes sense). |
@tkf Thanks for your reply. But there are still some questions:
Thanks. |
I think there are three ways to use Python with Julia 1.0 on Ubuntu/Debian/etc. at the moment:
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 made an experimental package It implements the private
|
@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-installedfor test purpose, I test 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 callbroadcast is commonly used in julia, but
which 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
|
@Hong-Xiang Hey, thanks for the feedback. Are you using
Yeah, something like
I started experimenting more numpy-like interface on top of PyJulia (i.e., broadcast operations on arrays by default): https://ipyjulia-hacks.readthedocs.io/en/latest/ Not sure if it is suitable for PyJulia, though. But if you want to leverage Julia, I think it's better to just use Julia syntax. If you don't want to use global variable (of course), you can do: Main.eval("(xs) -> sin.(exp.(xs) .+ 1)")(xs) or equivalently Main.eval("(xs) -> @. sin(exp(xs) + 1)")(xs) Unlike
Hmm... I didn't notice that. But yes, I can reproduce it. Actually, I just noticed that it's reported in #189. Let's track the issue there. It looks like IPython 7 (development version) handle ctrl-C differently and it doesn't have this problem. I've been using it so I didn't notice the problem. |
@tkf my system/environment info is:
and actually it's Ubuntu Mate. conda:
python(in conda virutal env, with
it worked, without error. python(in conda virtual env, without
tests like using standard libraries, basic array operations and even third-party packages like |
Thanks. Interesting... Actually, the problem I thought I had was already fixed tkf/julia-venv#2. My guess was that it was some kind of IO caching issue (compilation file was not properly written before exiting the problem). It then maybe explains why it's machine-dependent. Anyway, I'm glad that it worked in your machine! |
For Ubuntu/Debian users, probably the cleanest and relatively easy way to use PyJulia at the moment is to install (build) Python using pyenv. But you need to pass $ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.6
Downloading Python-3.6.6.tar.xz...
-> https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
Installing Python-3.6.6...
Installed Python-3.6.6 to /home/takafumi/.pyenv/versions/3.6.6
200.54s user 16.69s system 271% cpu 1:20.10 total
$ ldd ~/.pyenv/versions/3.6.6/bin/python3.6
linux-vdso.so.1 => (0x00007fff6933c000)
libpython3.6m.so.1.0 => /home/takafumi/.pyenv/versions/3.6.6/lib/libpython3.6m.so.1.0 (0x00007fca44c8b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fca44a6e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fca446a4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fca444a0000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fca4429d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fca43f94000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca451c0000)
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial |
Or you can switch to Arch Linux 😆 It uses |
@ExpandingMan @mprogram So it turned out static linking is just the default behavior of Python's |
Thanks, @tkf for your last two comments. I'm a fan of deb-based system and my thought would be that Debian needs to look at those. If I'll be up to recompile Python (for the sake of optimization with MKL, for example as Julia does), I would include the |
@mprogram It looks like pyenv does something more than passing
I didn't check if |
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 |
Yeah "switch to Arch Linux" was rather a joke... 😉 It definitely is the biggest TODO in this package to support Debian family out-of-the-box.
I don't think the question is how to solve the problem. In principle there is a straightforward solution: just compile different cache of PyCall.jl and all other packages depending on it to different files. For example, here is an idea to implement it: JuliaLang/julia#27418 (comment). The question is when that happens. Or maybe it's more like if we can convince Julia core devs to include enough features required by PyJulia. Until then, here is yet another solution: #200. The idea is to bundle |
I think I'm rather confused about what the issue is here. I thought the problem was that since the debian Python binary is statically linked, using |
You can interact with C API of statically linked The reason why it's related to Julia's precompilation mechanism is explained in |
I merged a workaround for statically linked Python #200. Basically, you "just" need to run
|
Awesome job! Thanks so much for your work on this. This was a really awkward problem in which we were basically just getting screwed by the distros (and sadly some of the most important ones) and there was really never going to be a perfect solution, this seems to be about the best we'll be able to do with the situation we've been put in. If you could, I think it would be really great if you could explain this as much as possible in the README (I won't offer to do it myself since I'm not sure I fully understand what you did yet). Thanks again! |
Yep, README is the only blocker before the release ATM. |
Guys I might have found a solution to this! If you install python from conda-forge there is no need for
It should work. See #212 (comment) |
How is that a better solution than |
If you are using Conda you are already not using the system Python binaries. In the other cases, I agree there is still need for |
Agreed, let's just aim to document as many options as possible and people will be able to select whatever solution works best for them. |
@bstellato Thanks!. This is a good news! So I guess @ExpandingMan Yeah, I think |
It's a bit strange. 3.7.0 from conda-forge is statically linked: $ conda create --prefix conda-forge-python conda-forge::python
...
The following NEW packages will be INSTALLED:
...
python: 3.7.0-h5001a0f_4 conda-forge
...
$ conda-forge-python/bin/python
Python 3.7.0 | packaged by conda-forge | (default, Sep 30 2018, 14:56:18)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ ldd conda-forge-python/bin/python
linux-vdso.so.1 (0x00007ffec5dce000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f86eb290000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f86eb28b000)
libutil.so.1 => /usr/lib/libutil.so.1 (0x00007f86eb286000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f86eb27c000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f86eb0f7000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f86eaf33000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f86eb2e4000)
$ conda-forge-python/bin/python -c 'from julia.find_libpython import linked_libpython; print(linked_libpython())'
None But $ rm -r conda-forge-python
$ conda create --prefix conda-forge-python conda-forge::python=3.6
...
The following NEW packages will be INSTALLED:
...
python: 3.6.6-h5001a0f_3 conda-forge
...
$ ldd conda-forge-python/bin/python
linux-vdso.so.1 (0x00007ffff0f7e000)
libpython3.6m.so.1.0 => /home/takafumi/repos/pyjulia/conda-forge-python/bin/../lib/libpython3.6m.so.1.0 (0x00007f1f758a8000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1f75856000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f1f75851000)
libutil.so.1 => /usr/lib/libutil.so.1 (0x00007f1f7584c000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f1f75842000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f1f756bd000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f1f754f7000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f1f75de7000)
$ conda-forge-python/bin/python -c 'from julia.find_libpython import linked_libpython; print(linked_libpython())'
/home/takafumi/repos/pyjulia/conda-forge-python/lib/libpython3.6m.so.1.0 |
Version 3.7.0 is still dynamically linked for me on mac os.
I get
Also,
|
Interesting. I asked the question in conda-forge: conda-forge/python-feedstock#222 |
I wrote README in #210 and you can read it here: https://github.com/tkf/pyjulia/blob/readme/README.md @ExpandingMan If you are interested, have a look at Troubleshooting and pre-compilation mechanism sections: |
I just merged #256 to master. I think PyJulia is now usable with many CPython executables if you can compile a custom system image with |
Hi @tkf - it's annoying having to deal with this issue. Do you know which Linux distro (ideally docker container) that provides a dynamically linked Python? |
It works in Arch Linux :) IIRC, the official Also, just FYI, I started working on compile-time preference integration for PyCall JuliaPy/PyCall.jl#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 ;) |
What's the status of this issue? I am trying to run PyJulia in Ubuntu 22 but python is statically linked. |
Is it possible to build my own Python with |
I think that might be a question for conda-forge. If you are going to compile it yourself, do you actually need conda though? Perhaps we could use https://github.com/JuliaBinaryWrappers/Python_jll.jl |
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 Support virtualenv/venv without separate cache #190 is merged)have exactly identical paths.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:
where
/usr/bin/python
is the appropriate Python interpreter.If it does not print anything, you can't use PyJulia with this Python interpreter.
The text was updated successfully, but these errors were encountered: