can't get pyjulia to work

1,254 views
Skip to first unread message

Neal Becker

unread,
Mar 1, 2016, 10:40:03 AM3/1/16
to julia...@googlegroups.com
From time-to-time, I get interested in trying out moving some of my work
from python to julia. Before I can even start, I need to be able to call
from python to julia. But I've never gotten pyjulia to work on linux/fedora
(currently 23). I've tried the fedora version of julia (0.4.3), and I've
built my own julia today from master, and in both cases I get:

j = julia.Julia (jl_init_path='/home/nbecker/julia')
ERROR: UndefVarError: dlpath not defined
in eval(::Module, ::Any) at ./boot.jl:267
[inlined code] from ./sysimg.jl:14
in process_options(::Base.JLOptions) at ./client.jl:239
in _start() at ./client.jl:318
Traceback (most recent call last):
File "/home/nbecker/pyjulia/julia/core.py", line 238, in __init__
"""])
File "/usr/lib64/python3.4/subprocess.py", line 620, in check_output
raise CalledProcessError(retcode, process.args, output=output)
subprocess.CalledProcessError: Command
'['/home/nbecker/julia/usr/bin/julia', '-e', '\n
println(JULIA_HOME)\n
println(Sys.dlpath(dlopen("libjulia")))\n ']' returned
non-zero exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nbecker/pyjulia/julia/core.py", line 244, in __init__
raise JuliaError('error starting up the Julia process')
julia.core.JuliaError: error starting up the Julia process

Páll Haraldsson

unread,
Mar 4, 2016, 3:58:34 AM3/4/16
to julia-users, ndbe...@gmail.com
Since I'm more of a Julia user (or including calling Python) I'm not sure I can help you too much. I would however find it interesting to know if/when pyjulia works. If been following commits and see a big pull request here:


Maybe this is the one, that will help you when it is committed. I do not know git[hub] enough to know if you can checkout [pyjulia] project with these additions:

EQt wants to merge 17 commits into JuliaLang:master from EQt:clean-julia-0.4

[or others for that matter.. there are many other pull requests (and issues) open.]

At EQt's page I saw (but not his own repository with the code):

Repositories contributed to

https://github.com/benmoran/pyjulia

I guess someone must review these changes (could be you?), or possibly waiting for them to get committed (by those who have the privileges) is the correct option.

PyCall.jl as you may know allows for calling in the other direction. pyjulia reuses it, but I saw something about it needing it's own PyCall.. (so they can develop in independent directions(?), seems like a bad idea); maybe I misunderstood..


May I ask what you are doing with your own code? Or at least what Python Libraries/frameworks you use? In particular, if you use Django or similar? I would like to know if Django could be used with Julia, and then it seems pyjulia would be needed (not just PyCall).

I do not think you need to compile your own Julia. I could be wrong, just do not see the reason.

Maybe this, wasn't too helpful.. Is there another possibility, that you could just use PyCall?

Neal Becker

unread,
Mar 4, 2016, 8:18:18 AM3/4/16
to julia...@googlegroups.com
I'm not looking to call python libs from julia. I have a large investment
in python code. The obvious (to me) path to try out some julia is to move a
function or 2 into julia, and be able to call julia from my python main
program. So I would need a working pyjulia to do this.

Páll Haraldsson

unread,
Mar 4, 2016, 9:08:42 AM3/4/16
to julia-users, ndbe...@gmail.com
 
I'm not looking to call python libs from julia.  I have a large investment
in python code.  The obvious (to me) path to try out some julia is to move a
function or 2 into julia, and be able to call julia from my python main
program.  So I would need a working pyjulia to do this.

Yes, my PyCall.jl, suggestion, was probably not to helpful.. While you can use it to call TO Julia, using callbacks I guess, I assume you would be reimplementing pyjulia on your own from scratch..

Calling from Python, for sure worked at some point even recursively (might not be well tested, even less that only pyjulia) back and forth:

Julia Calling Python Calling Julia...


Now, I'm not sure what changed, at least Julia 0.4 came along and something broke pyjulia. You could help or wait for it to get fixed. OR if you are just trying out, you could use what did work. I think that would then be Julia 0.3.12:

A.


Is it preferred. No, but ok, to start out trying Julia.. 0.4 sure got better, e.g. faster/incremental GC, but Julia sure was fast in 0.3, and even 0.2.

These major version upgrades DID break some syntax (why they are major versions). Some are trivial changes, such as case of integer types. It would get annoying having to change but not you can use the newer syntax using Compat.jl. And you do not have to actually specify the type that often (never for speed).

B.

PyCall or pyjulia would almost always be preferred to that, except when it's not :) e.g. say running on different machines, or when, say either, e.g. the latter pyjulia doesn't work. This is still a neat project (at least for other languages), that I haven't tried. Hopefully 0.4 didn't break it..

-- 
Palli.


Diego Javier Zea

unread,
Mar 14, 2016, 5:03:46 PM3/14/16
to julia-users, ndbe...@gmail.com
I'm also having troubles with pyjulia...  Is there a way to solve this problem? Best

diego@SIRRAH:~$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.1 (2015-11-08 10:33 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/                   |  x86_64-linux-gnu

julia> Pkg.installed("PyCall")
v"1.4.0"

julia> 
diego@SIRRAH:~$ python
Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> j = julia.Julia()
ERROR: UndefVarError: dlpath not defined
 in process_options at ./client.jl:257
 in _start at ./client.jl:378
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/diego/.local/lib/python2.7/site-packages/julia/core.py", line 244, in __init__

Eric Forgy

unread,
Mar 14, 2016, 8:34:03 PM3/14/16
to julia-users, ndbe...@gmail.com
I have never used Python, but hearing your scenario, I wonder if a Julia API might be acceptable?

Yesterday, I've submitted a package to METADATA I use quite a lot for my own work with similar scenarios (Pages). I use it mostly for calling Julia from JavaScript (and vice versa), but it would work for any language that supports HTTP requests and WebSockets.

If it interested, I could help get you set up so you can start experimenting with it.

PS: Until it is merged to METADATA (:pray:), the installation instructions would be


instead of 

Pkg.add("Pages")

Best regards,
Eric

Eric Forgy

unread,
Mar 14, 2016, 10:50:28 PM3/14/16
to julia-users, ndbe...@gmail.com
Btw, I had a quick look at pyjulia. It is very cool and works with PyCall.jl to handles conversions etc. My solution is much less grand, but would work if the arguments to your calls to Julia are simple and could be serialized to JSON.

Nirav Shah

unread,
May 27, 2016, 8:07:40 AM5/27/16
to julia-users, ndbe...@gmail.com
I tried this for first time today and I see same exact error :(
I can run PyCall and it's version is 1.6.1+. So I assume problem is in pyjulia
Message has been deleted

Tim Wheeler

unread,
Jul 11, 2016, 12:46:56 PM7/11/16
to julia-users
Have there been updates to this issue? I am seeing the same "ERROR: UndefVarError: dlpath not defined" problem.

I tried running git checkout v1.3.0 as recommended, and then rebuilt with

1) Delete ~/.julia/lib
2) Run in julia:
2.1) ENV["PYTHON"] = " ... path to python ... "
2.2) Pkg.build("PyCall")
2.3) using PyCall

as recommended. So far no luck.

I am using ubuntu 14.04 and Python 2.7.10 | Anaconda 2.3.0 (64-bit)

Tim Wheeler

unread,
Jul 11, 2016, 1:30:26 PM7/11/16
to julia-users
So I may have figured it out.

According to here, one needs to:
  1. Tag PyCall.jl at v1.3.0
  2. Use the pull request from benmoran
Tagging is accomplished by navigating to the PyCall.jl package directory and running git checkout v1.3.0.
I wasn't sure how to install the pull request, so I overwrite the only changed file, core.py, in the pyjulia package source using benmoran's version. The installed package location can be found in python:

```
import julia
julia.__file__
```

The error has gone away. Hopefully it continues to work!

Keno Fischer

unread,
Jul 11, 2016, 2:24:00 PM7/11/16
to julia...@googlegroups.com
I've been working on making this work again. Should be merged in a
couple of days.

Tim Wheeler

unread,
Aug 9, 2016, 6:05:29 PM8/9/16
to julia-users
Was this fixed?

Keno Fischer

unread,
Aug 9, 2016, 6:19:02 PM8/9/16
to julia...@googlegroups.com
Should have been, yes.

Christoph Ortner

unread,
Aug 9, 2016, 6:39:53 PM8/9/16
to julia-users
seems to work for me.

Tim Wheeler

unread,
Aug 9, 2016, 7:05:50 PM8/9/16
to julia-users
Okay,  thank you!
We are trying to get it to work on another computer.

Alex Kuefler

unread,
Aug 9, 2016, 8:28:14 PM8/9/16
to julia-users, ndbe...@gmail.com
After calling Pkg.Build("PyCall") I'm still having the same issue with 1.7.0. When I run julia from python:

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 

[GCC 4.8.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import julia

>>> julia.Julia()

ERROR: UndefVarError: dlpath not defined

 in process_options at ./client.jl:257

 in _start at ./client.jl:378

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/home/alex/.local/lib/python2.7/site-packages/julia/core.py", line 244, in __init__

    raise JuliaError('error starting up the Julia process')

julia.core.JuliaError: error starting up the Julia process



On Tuesday, March 1, 2016 at 7:40:03 AM UTC-8, Neal Becker wrote:

Tim Wheeler

unread,
Aug 23, 2016, 1:58:38 PM8/23/16
to julia-users, ndbe...@gmail.com
So here is what I did:

in Julia v0.4.6:

julia> Pkg.pin("PyCall", v"1.3.0")
julia> Pkg.build("PyCall")

removed core.py in /usr/local/lib/python2.7/dist-packages/julia/
created a new core.py containing these contents.

running, in python:

>>> import julia
>>> julia.Julia()

works fine.

Tim Wheeler

unread,
Sep 23, 2016, 6:01:10 PM9/23/16
to julia-users, ndbe...@gmail.com
Another pyjulia call for help.

I am using Julia 0.5 and Anaconda 2.3.0 with Python 2.7. I followed the pycall install instructions. Julia is on my PATH.
When I run python in the cloned pyjulia repo everything is fine.
When I run python in a different directory I get the following error:

>>> import julia
>>> j = julia.Julia(debug=True)
JULIA_HOME = /bin,  libjulia_path = /bin/../lib/x86_64-linux-gnu/libjulia.so.0.5
calling jl_init(/bin)
seems to work...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tim/anaconda/lib/python2.7/site-packages/julia/core.py", line 288, in __init__
    self.api.jl_bytestring_ptr.restype = char_p
  File "/home/tim/anaconda/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "/home/tim/anaconda/lib/python2.7/ctypes/__init__.py", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /bin/../lib/x86_64-linux-gnu/libjulia.so.0.5: undefined symbol: jl_bytestring_ptr

Is this a path issue? Do I need to add the cloned pyjulia repo to my path or something?

Thank you.

Tim Wheeler

unread,
Sep 23, 2016, 7:12:59 PM9/23/16
to julia-users, ndbe...@gmail.com
So a temporary workaround is:

export PYTHONPATH=$HOME/Desktop/pyjulia:$PYTHONPATH

This just adds the pyjulia repo to my PYTHONPATH.
Reply all
Reply to author
Forward
0 new messages