juliapy / pyjulia Goto Github PK
View Code? Open in Web Editor NEWpython interface to julia
License: MIT License
python interface to julia
License: MIT License
jl.sind(90) AttributeError: 'Julia' object has no attribute 'sin
I installed julia from the ubuntu repository, and I also tested compiling the version 0.3, and it still does not work.
I'm trying to run the program "test_core.py" and I get:
python test_core.py
ERROR: dlpath not defined
in process_options at client.jl:242
in _start at client.jl:389
Traceback (most recent call last):
File "test_core.py", line 7, in <module>
julia = Julia()
File "/usr/local/lib/python2.7/dist-packages/julia/core.py", line 228, in __init__
raise JuliaError('error starting up the Julia process')
julia.core.JuliaError: error starting up the Julia process
The same error appears when I just try (inside python)
import julia
julia.Julia()
I cannot start Julia process. The error emerges here.
It is FileNotFoundError
:
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 21))
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-ddd7576f83cf> in <module>()
4 println(JULIA_HOME)
5 println(Sys.dlpath(dlopen(\"libjulia\")))
----> 6 """])
c:\Miniconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
605 else:
606 inputdata = None
--> 607 with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
608 try:
609 output, unused_err = process.communicate(inputdata, timeout=timeout)
c:\Miniconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
857 c2pread, c2pwrite,
858 errread, errwrite,
--> 859 restore_signals, start_new_session)
860 except:
861 # Cleanup if the child failed starting.
c:\Miniconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1110 env,
1111 cwd,
-> 1112 startupinfo)
1113 finally:
1114 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] Nie można odnaleźć określonego pliku
It does not appear when using shell=True
in the call to check_output
.
However, using shell=True
brings about yet another error:
juliainfo = subprocess.check_output(['julia', "-e", "println(JULIA_HOME)"], shell=True)
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
<ipython-input-19-5463769c8183> in <module>()
----> 1 juliainfo = subprocess.check_output(['julia', "-e", "println(JULIA_HOME)"], shell=True)
c:\Miniconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
618 retcode = process.poll()
619 if retcode:
--> 620 raise CalledProcessError(retcode, process.args, output=output)
621 return output
622
CalledProcessError: Command '['julia', '-e', 'println(JULIA_HOME)']' returned non-zero exit status 1
which is kind of weird because julia -e println(JULIA_HOME)
works from cmd
...
Any ideas?
I'm on windows 8, Julia 0.4.1, Python 3.5
karan@karan-Ubuntu:~/pyjulia$ 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.
from julia import Julia
'>>> j = Julia()
WARNING: redefining constant JULIA_HOME
Traceback (most recent call last):
File "", line 1, in
File "julia/core.py", line 353, in init
self._call(u"using PyCall")
File "julia/core.py", line 391, in _call
ans = self.api.jl_eval_string(src.encode('utf-8'))
TypeError: PyModule_AddObject() needs module as first arg
I installed this package and when I try to get a handle to Julia (j=julia.Julia()) I get the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\julia\core.py", line 228, in init
raise JuliaError('error starting up the Julia process')
JuliaError: error starting up the Julia process
I am running Python 2.7, and Julia 0.2. Is there an issue with my versions, or is there some other reason it can't seem to find Julia?
Thanks for the help.
[Macintosh-3:~] solver% /Users/solver/.julia/v0.5/Conda/deps/usr/bin/python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import julia
>>> j = julia.Julia()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/solver/.julia/v0.5/Conda/deps/usr/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.py", line 271, in __init__
"""])
File "/Users/solver/.julia/v0.5/Conda/deps/usr/lib/python2.7/subprocess.py", line 567, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/Users/solver/.julia/v0.5/Conda/deps/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/Users/solver/.julia/v0.5/Conda/deps/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
This is basically the same issue as JuliaLang/IJulia.jl#220
When I run the tests, instantiating a Julia
object looks for /usr/lib/libjulia.so
. However, on Debian-based systems, this is installed to /usr/lib/x86_64-linux-gnu/julia/libjulia.so
(and the location presumably depends on the system architecture, so hardcoding it wouldn't work). I'm not sure how to calculate that path.
Hi Jake,
By mixing part from IJulia\python to your, I can build a installable module.
Where shall I merge all that ? Either code from IJulia goes to you, and we shall put the licence from IJulia ? either your code goes back to IJulia
Hi,
When I try to start up the julia process from the python prompt, it hangs forever (>1min). If I kill it with control-C, I get the following error:
>>> import julia
>>> j = julia.Julia()
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/madeleine/anaconda/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.py", line 291, in __init__
raise JuliaError("Failed to initialize PyCall package")
julia.core.JuliaError: Failed to initialize PyCall package
Otherwise, it segfaults:
signal (11): Segmentation fault: 11
uv_dlsym at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/deps/libuv/src/unix/dl.c:57
jl_dlsym at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/dlload.c:176
dlsym at c.jl:15
Py_GetVersion at /Users/madeleine/.julia/v0.3/PyCall/src/pyinit.jl:292
pyinitialize at /Users/madeleine/.julia/v0.3/PyCall/src/pyinit.jl:133
pyinitialize at /Users/madeleine/.julia/v0.3/PyCall/src/pyinit.jl:119
jlcall_pyinitialize;1142 at (unknown line)
jl_apply at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/gf.c:1416
jl_apply at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/interpreter.c:59
eval at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/interpreter.c:207
jl_toplevel_eval_flex at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/toplevel.c:496
jl_eval_string at /Users/vagrant/tmp/julia-packaging/osx10.7+/julia-master/src/jlapi.c:87
ffi_call_unix64 at /Users/madeleine/anaconda/lib/python2.7/lib-dynload/_ctypes.so (unknown line)
ffi_call at /Users/madeleine/anaconda/lib/python2.7/lib-dynload/_ctypes.so (unknown line)
_ctypes_callproc at /Users/madeleine/anaconda/lib/python2.7/lib-dynload/_ctypes.so (unknown line)
PyCFuncPtr_call at /Users/madeleine/anaconda/lib/python2.7/lib-dynload/_ctypes.so (unknown line)
PyObject_Call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
function_call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyObject_Call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
instancemethod_call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyObject_Call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
slot_tp_init at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
type_call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyObject_Call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
function_call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyObject_Call at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalFrameEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCodeEx at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyEval_EvalCode at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyRun_FileExFlags at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
PyRun_SimpleFileExFlags at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
Py_Main at /Users/madeleine/anaconda/lib/libpython2.7.dylib (unknown line)
[1] 19405 segmentation fault ipython
For reference, I'm running julia 3.1, python 2.7, PyCall is indeed installed, and running python -m unittest discover
from the main pyjulia directory also segfaults.
When calling a custom Julia function from Python and parsing a numpy array as input, it only works when the dimensions of the array are small.
import os
import numpy as np
import julia
# provide absolute path to r module file
libpath = 'path/to/test/file'
module_file = 'test.jl'
module_file = os.path.join(libpath, module_file)
# start the julia engine and include jl file
print 'start julia engine'
j = julia.Julia() # starting the julia engine this takes forever!
print 'include julia file: "%s"' % module_file
j.eval('include("{0}")'.format(module_file))
# call the jl module with some arguments and assign it to a variable
dims = (10, 10) # works with (5, 5)
py_var = np.random.random(dims)
print 'evaluate julia function and assign result to variable'
jl_var = j.eval('test({0})'.format(py_var))
print 'type of variable:\n{0}'.format(type(jl_var))
print 'dimensions of variable:\n{0}'.format(jl_var.shape)
print 'value of variable:\n{0}'.format(jl_var)
print 'type of elements in variable:\n{0}'.format(jl_var.dtype)
np.testing.assert_array_equal(jl_var, py_var,
err_msg='input and output are not identical')
# when dims = (5, 5) raises AssertionError despite correct type, dimensions, and values???
This is the content of the test.jl
file:
function test(x)
return x
end
When dims = (10, 10)
the above Python code produces the following error message:
Traceback (most recent call last):
File "test_j_module.py", line 21, in <module>
jl_var = j.eval('test({0})'.format(py_var))
File "/usr/local/lib/python2.7/site-packages/julia/core.py", line 329, in call
.format(exception_type, exception_msg, src))
julia.core.JuliaError: Exception 'ErrorException' ocurred while calling julia code:
<couldn't get stack>
Code:
test([[ 0.20682803 0.04704934 0.13274106 0.05469292 0.40254676 0.18466478
0.84020545 0.99678851 0.47026452 0.61415764]
[ 0.00901351 0.00545614 0.36920023 0.59153858 0.93464972 0.5847787
0.88878481 0.45640786 0.48818201 0.65426845]
[ 0.79333042 0.06071264 0.35143529 0.15739708 0.38740339 0.63253983
0.13512716 0.67442572 0.99706677 0.12753637]
[ 0.26065309 0.00170454 0.28043126 0.40828326 0.86559628 0.60525831
0.96192417 0.91599325 0.67131462 0.97354081]
[ 0.42094702 0.82631545 0.44081515 0.95666598 0.65161472 0.58373058
0.20209026 0.17087424 0.6004557 0.48976695]
[ 0.71146331 0.42216148 0.80070431 0.08453404 0.72486401 0.84377365
0.58063987 0.66267037 0.69185328 0.90252447]
[ 0.95943342 0.78431303 0.36191132 0.23996024 0.0625853 0.68399853
0.96369497 0.69657076 0.05399353 0.86838642]
[ 0.66141604 0.00102945 0.31846223 0.80442309 0.81558502 0.52736737
0.07361813 0.74874239 0.3049418 0.73352948]
[ 0.40454631 0.54091448 0.57932001 0.55639143 0.99712401 0.96816375
0.16446963 0.95342441 0.72510795 0.74854267]
[ 0.66389913 0.07991279 0.817699 0.65261875 0.57849456 0.53964192
0.80881346 0.8784131 0.1920992 0.41979808]])
When dims = (5, 5)
it produces the following error message:
Traceback (most recent call last):
File "test_j_module.py", line 31, in <module>
err_msg='input and output are not identical')
File "/usr/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 739, in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/usr/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 665, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal
input and output are not identical
(mismatch 100.0%)
x: array([[ 0.618968, 0.501059, 0.143219, 0.721154, 0.134409],
[ 0.845478, 0.100637, 0.184674, 0.994752, 0.030494],
[ 0.508936, 0.699266, 0.678141, 0.08459 , 0.622509],...
y: array([[ 0.618968, 0.501059, 0.143219, 0.721154, 0.134409],
[ 0.845478, 0.100637, 0.184674, 0.994752, 0.030494],
[ 0.508936, 0.699266, 0.678141, 0.08459 , 0.622509],...
Trying to instantiate the Julia
class from Python 3.4, there is an AttributeError
due to dict changes in Python 3.
Python 3.4.1 (default, May 19 2014, 10:17:08)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from julia import Julia
In [2]: jl = Julia()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-d3558c878154> in <module>()
----> 1 jl = Julia()
/home/simon/workspace/euroscipy2014/julia/pyjulia/julia/core.py in __init__(self, init_julia, jl_init_path)
275 sys._julia_runtime = self.api
276
--> 277 for name, func in base_functions(self).iteritems():
278 setattr(self, name, func)
279
AttributeError: 'dict' object has no attribute 'iteritems'
hi,
On Windows 32 bit mode, I get a fully functional Julia/Pyjulia/Juliamagic/IJulia
On Windows 64bit mode, I have two strange events, that may be related:
Timeout waiting for kernel_info reply
error initializing module LinAlg
ccall: could not find function openblas_get_config_64_ in library openblas
side note: in my path, the openblas library given per Carl Kleffner (for python), is before the openblas potentially in julia dll list
==> there could be a mutual incompatibility issue there, but I don't guess how to solve it
https://bitbucket.org/carlkl/mingw-w64-for-python/downloads
based on gcc-4.9.2 right now as well as an update of the openblas-0.2.12 builds
def pcallj():
jl = Julia()
f=jl.eval("""
function abc(frame,r,c)
for x in (0:r)
for y in (0:c)
g[x,y]=((((frame[x,y,0]*0.144)+frame[x,y,1]*0.587)+frame[x,y,2]*0.299))
end
end
return g
end
""")
return f
Here frame is RGB of image and r is row size and c is column size.
I have no print statement but still it prints this on terminal infinitely.
WARNING: redefining constant JULIA_HOME
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc 0xfc
This is same for broadcast of arrays too.
jl = Julia()
f=jl.eval("""
function abc(frame,rows,cols)
g = zeros(rows,cols)
""")
Initializing the array starts printing this on terminal.
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
It would be awesome to see PyJulia registered in the Python Package Index (PyPI), be it now or some time in the future.
I'm trying to run the basic example code from the README:
import julia
j = julia.Julia()
I get the following traceback:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-f420be51b3fc> in <module>()
----> 1 j = julia.Julia()
/home/dcriger/.local/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.pyc in __init__(self, init_julia, jl_runtime_path, jl_init_path, debug)
275 if not os.path.exists(libjulia_path):
276 raise JuliaError("Julia library (\"libjulia\") not found! {}".format(libjulia_path))
--> 277 self.api = ctypes.PyDLL(libjulia_path, ctypes.RTLD_GLOBAL)
278 if not jl_init_path:
279 if jl_runtime_path:
/home/dcriger/anaconda2/lib/python2.7/ctypes/__init__.pyc in __init__(self, name, mode, handle, use_errno, use_last_error)
360
361 if handle is None:
--> 362 self._handle = _dlopen(self._name, mode)
363 else:
364 self._handle = handle
OSError: /home/dcriger/anaconda2/lib/python2.7/site-packages/matplotlib/../../../libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1)
I have multiple copies of libstdc++.so.6
on my computer. One of them is in ~/anaconda2/lib/
, where pyjulia
finds it. running strings
on this file, I can see that it contains GLIBCXX_3.4
and GLIBCXX_3.4.1
up to GLIBCXX_3.4.21
, but not GLIBCXX_3.4.22
. There is another libstdc++.so.6
in /usr/lib/x86_64-linux-gnu/
which does contain GLIBCXX_3.4.22
.
Should I:
pyjulia
can find the newer file,pyjulia
is already searching, orIt's currently possible to get pyjulia to work, at least on Linux, by using PyCall.jl at tag v1.3.0 together with this PR for PyJulia: #47
But a proper solution is still needed. @stevengj has some suggestions here:
JuliaPy/PyCall.jl#219 (comment)
In particular he suggests that each pyjulia ought to make a separate Pkg.clone of PyCall, and Pkg.build it specializing to the instance of Python that is being used.
Hi,
I am having an issue starting pyjulia on Windows 10. When I run
j = julia.Julia()
I receive the following dialog saying:
The procedure entry point _ZSt24_throw_out_of_range_fmtPKcz could not be located in the dynamic link library C:...\Julia-0.5.0\bin\LLVM-3.7.dll
This is followed by another dialog with the same message regarding libjulia.dll
I am using Version 0.5.0 (2016-09-19 18:14 UTC | x86_64-w64-mingw32 of Julia.
I believe I have followed your installation instructions .For installing PyCall, I set the python environment to '' and PyCall downloaded a conda installation. It may have downloaded a 32 bit version of python.
Thanks for your help in advance.
karan@karan-Ubuntu:~$ python3
Python 3.4.3 (default, Sep 14 2016, 12:36:27)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
from julia import Julia
j = Julia()
WARNING: redefining constant JULIA_HOME
InitError(:PyCall,PyError (:PyImport_ImportModule) <class 'SystemError'>
SystemError('initialization of _opcode did not return an extension module',)
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
PyObject_Call at /usr/bin/../lib/x86_64-linux-gnu/libpython3.4m.so (unknown line)
macro expansion at /home/karan/.julia/v0.5/PyCall/src/exception.jl:78 [inlined]
#_pycall#62 at /home/karan/.julia/v0.5/PyCall/src/PyCall.jl:546
jl_call_method_internal at /build/julia-hCoRih/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-hCoRih/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-hCoRih/julia-0.5.0/src/julia.h:1392 [inlined]
jl_f__apply at /build/julia-hCoRih/julia-0.5.0/src/builtins.c:547
_pycall at /home/karan/.julia/v0.5/PyCall/src/PyCall.jl:534
jl_call_method_internal at /build/julia-hCoRih/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-hCoRih/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-hCoRih/julia-0.5.0/src/julia.h:1392 [inlined]
jl_f__apply at /build/julia-hCoRih/julia-0.5.0/src/builtins.c:547
#pycall#65 at /home/karan/.julia/v0.5/PyCall/src/PyCall.jl:565
show at /home/karan/.julia/v0.5/PyCall/src/exception.jl:39
unknown function (ip: 0x7f94f7acd1f6)
jl_call_method_internal at /build/julia-hCoRih/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-hCoRih/julia-0.5.0/src/gf.c:1942
show_default at ./show.jl:130
unknown function (ip: 0x7f94f7acbbf6)
jl_call_method_internal at /build/julia-hCoRih/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-hCoRih/julia-0.5.0/src/gf.c:1942
show at ./show.jl:116
unknown function (ip: 0x7f94f7acb656)
jl_call_method_internal at /build/julia-hCoRih/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-hCoRih/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-hCoRih/julia-0.5.0/src/julia.h:1392 [inlined]
jl_show at /build/julia-hCoRih/julia-0.5.0/src/builtins.c:972
ffi_call_unix64 at /usr/lib/x86_64-linux-gnu/libffi.so.6 (unknown line)
ffi_call at /usr/lib/x86_64-linux-gnu/libffi.so.6 (unknown line)
_ctypes_callproc at /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7f970bbd66a2)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalCodeEx at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
unknown function (ip: 0x56ab58)
unknown function (ip: 0x547f8c)
PyObject_Call at python3 (unknown line)
unknown function (ip: 0x5159f9)
unknown function (ip: 0x4c0635)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalCode at python3 (unknown line)
unknown function (ip: 0x4bc83d)
PyRun_InteractiveOneObject at python3 (unknown line)
PyRun_InteractiveLoopFlags at python3 (unknown line)
PyRun_AnyFileExFlags at python3 (unknown line)
Py_Main at python3 (unknown line)
main at python3 (unknown line)
__libc_start_main at /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287
unknown function (ip: 0x574360)
Allocations: 2216998 (Pool: 2216088; Big: 910); GC: 1
Segmentation fault (core dumped)
Should the IPython julia magics be incorporated into the pyjulia
package? It probably makes more sense here than in IJulia. (See also JuliaLang/IJulia.jl#80)
Also, should pyjulia
be moved to JuliaLang, to give it a higher profile and access among Julia maintainers?
cc: @StefanKarpinski, @fperez
I am attempting to get pyjulia to run on Linux mint 17.3 (Ubuntu derivative). I have installed latest version of Julia from precompiled repositories (official) and latest version of pyjulia from Github.
Loading the pyjulia module works, but creating a Julia object results in the following output:
import julia
j = julia.Julia()
ErrorException("Using pyjulia with a statically-compiled version\nof python or with a version of python that\ndiffers from that used by PyCall.jl is not\nsupported on julia 0.4")Traceback (most recent call last):
File "", line 1, in
File "julia/core.py", line 332, in init
""")
File "julia/core.py", line 392, in _call
self.check_exception(src)
File "julia/core.py", line 412, in check_exception
.format(exception_type, src))
julia.core.JuliaError: Exception 'ErrorException' occurred while calling julia code:if VERSION < v"0.5-" error("""Using pyjulia with a statically-compiled version of python or with a version of python that differs from that used by PyCall.jl is not supported on julia 0.4""") end
I have both python2.7 and python3 installed but the python shell above was started using python2.7.
Further debugging against the error message lead me to the option of specifying the python version used by PyCall (Julia package).
In a Julia shell:
ENV["PYTHON"] = "/usr/bin/python2.7"
Pkg.build("PyCall")
using PyCall
This does not resolve the problem. The specific python version I am using is 2.7.6 and Julia version 0.4.6
Any assistance would be appreciated.
I work with pyjulia on a cluster, where I work in a python virtualenv. In the past, I have successfully launched pyjulia from python with:
julia = Julia(jl_runtime_path=juliaBinPathB, debug=False)
Now I would like to point to a different julia binary (I don't have write access to juliaBinPathA, so if there's a bug fix which I would like to have, I need to point to another julia binary, juliaBinPathB, which I have downloaded myself).
Calling
julia = Julia(jl_runtime_path=juliaBinPathA, debug=True)
produces the seg fault below. What can I do to change the working binary without such an issue?
I was trying to use this in an ipython notebook to support julia v0.4 but ran into this exception.
JuliaError: error starting up the Julia process.
The problem is in core.py:237
in 0.4 Sys.dlpath
does not exist it was moved to Libdl.dlpath
.
I don't know how large of an effort will be needed to get this working on 0.4 but I would rather file the issue than lose the information.
Eval is having trouble grabbing the Julia result and bringing it back into Python. This is running on Julia master, PyJulia master, and recently installed/updated PyCall.
In [1]: import julia
In [2]: pdb
Automatic pdb calling has been turned ON
In [3]: jl = julia.Julia(jl_init_path='/home/mrocklin/workspace/julia/')
JuliaError: ErrorException in Julia PyObject: names(Base)
> /home/mrocklin/workspace/pyjulia/julia/core.py(361)eval()
360 raise JuliaError("ErrorException in Julia PyObject: "
--> 361 "{}".format(src))
362 boxed_obj = self.api.jl_get_field(void_p(res), b'o')
ipdb> print ans
177549344
ipdb> print res
None
Hello,
I have still the "Failed to initialize PyCall package" (under windows Python3.4 32 bit, I'll test for other cases soon )
Change from before is that it doesn't work anymore if I replace "raise JuliaError" per a simpler "print"
D:\result_tests\WinPython-32bit-3.4.1.1_rc3\python-3.4.1\lib\site-packages\julia\core.py in __init__(self, init_julia, jl_init_path)
262 self.call('pyinitialize(C_NULL)')
263 except:
--> 264 raise JuliaError("Failed to initialize PyCall package")
265
266 # Whether we initialized Julia or not, we MUST create at least one
JuliaError: Failed to initialize PyCall package
import julia
j = julia.Julia(jl_runtime_path="/Users/inorton/git/julia/usr/bin/julia",
jl_init_path="/Users/inorton/git/julia/usr/bin")
j.addprocs(1)
#segfault
(segfault stack here)
Based on the stack trace, I thought there might be some issue with task switching because of ctypes (libffi) stack. However, running the following (equivalent?) code does not segfault:
JLPATH="/Users/inorton/git/julia"
import ctypes
jl = ctypes.PyDLL(JLPATH+"/usr/lib/libjulia.dylib", ctypes.RTLD_GLOBAL)
jl.jl_init(JLPATH+"/usr/bin/")
jl.jl_eval_string(""" addprocs(1) """)
jl.jl_eval_string(""" println(nprocs()) """)
# 2
Tested with 0.4.6, 0.5, and a several-day-old trunk build.
(cross-ref: https://discourse.julialang.org/t/julia-call-from-python3-running-in-single-core/508)
This issue has been discussed in Julia user groups (https://groups.google.com/d/msg/julia-users/oAWYShR1Pks/CYV8g2DyGeQJ).
Currently, importing Julia modules needs to be done this way:
1. import julia
2. j = julia.Julia()
3. j.call("using Clustering")
4. from julia import Clustering
Although not overly complicated, it would be convenient if the same could be achieved as:
1. import julia
2. from julia import Clustering
which is just like the original example by Jake Bolewski here.
I get the following segfault when I do j = julia.Julia()
on Python 3.5.
WARNING: redefining constant JULIA_HOME
InitError(:PyCall,PyError (:PyImport_ImportModule) <class 'SystemError'>
SystemError('initialization of _opcode did not return an extension module',)
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
PyObject_Call at /usr/bin/../lib/x86_64-linux-gnu/libpython3.5m.so (unknown line)
macro expansion at /home/savastio/.julia/v0.5/PyCall/src/exception.jl:78 [inlined]
#_pycall#62 at /home/savastio/.julia/v0.5/PyCall/src/PyCall.jl:546
jl_call_method_internal at /build/julia-0ecDfF/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-0ecDfF/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-0ecDfF/julia-0.5.0/src/julia.h:1392 [inlined]
jl_f__apply at /build/julia-0ecDfF/julia-0.5.0/src/builtins.c:547
_pycall at /home/savastio/.julia/v0.5/PyCall/src/PyCall.jl:534
jl_call_method_internal at /build/julia-0ecDfF/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-0ecDfF/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-0ecDfF/julia-0.5.0/src/julia.h:1392 [inlined]
jl_f__apply at /build/julia-0ecDfF/julia-0.5.0/src/builtins.c:547
#pycall#65 at /home/savastio/.julia/v0.5/PyCall/src/PyCall.jl:565
show at /home/savastio/.julia/v0.5/PyCall/src/exception.jl:39
unknown function (ip: 0x7f7f98d931f6)
jl_call_method_internal at /build/julia-0ecDfF/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-0ecDfF/julia-0.5.0/src/gf.c:1942
show_default at ./show.jl:130
unknown function (ip: 0x7f7f98d91c06)
jl_call_method_internal at /build/julia-0ecDfF/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-0ecDfF/julia-0.5.0/src/gf.c:1942
show at ./show.jl:116
unknown function (ip: 0x7f7f98d91686)
jl_call_method_internal at /build/julia-0ecDfF/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-0ecDfF/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-0ecDfF/julia-0.5.0/src/julia.h:1392 [inlined]
jl_show at /build/julia-0ecDfF/julia-0.5.0/src/builtins.c:972
ffi_call_unix64 at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
ffi_call at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
_ctypes_callproc at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7f81dfd4cfca)
PyObject_Call at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
unknown function (ip: 0x523de6)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalCodeEx at python3 (unknown line)
unknown function (ip: 0x4e3827)
PyObject_Call at python3 (unknown line)
unknown function (ip: 0x4f498d)
PyObject_Call at python3 (unknown line)
unknown function (ip: 0x54e948)
unknown function (ip: 0x5586ab)
PyObject_Call at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
unknown function (ip: 0x523de6)
PyEval_EvalCode at python3 (unknown line)
unknown function (ip: 0x5fd5f1)
PyRun_InteractiveOneObject at python3 (unknown line)
PyRun_InteractiveLoopFlags at python3 (unknown line)
unknown function (ip: 0x458aef)
unknown function (ip: 0x4cf513)
main at python3 (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at python3 (unknown line)
Allocations: 2217234 (Pool: 2216298; Big: 936); GC: 1
[1] 89582 segmentation fault (core dumped) python3
My PyCall package has been successfully compiled for Python 3.5.
Using unicode characters in the IPython notebook breaks julia magic:
%%julia
ϕ = 1
results in
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03d5' in position 0: ordinal not in range(128)
Replacing str() with unicode() fixes the issue for me:
diff --git a/julia/magic.py b/julia/magic.py
index 8ef0f00..255a3e5 100644
--- a/julia/magic.py
+++ b/julia/magic.py
@@ -54,7 +54,7 @@ class JuliaMagics(Magics):
Execute code in Julia, and pull some of the results back into the
Python namespace.
"""
- src = str(line if cell is None else cell)
+ src = unicode(line if cell is None else cell)
return self.julia.eval(src)
A documentation how to install and how to use pyjulia is missing.
It should be added to Readme.md.
hi,
I'm importing pyjulia0.3.2 from windows / python 3.4
I pre-set JULIA_HOME=D:\result_tests\WinPython-64bit-3.4.2.2_build2\python-3.4.2.amd64..\tools\Julia\bin\
I have sys.ji at
D:\result_tests\WinPython-64bit-3.4.2.2_build2\tools\julia\lib\julia\sys.ji
the current core.py set the following
libjulia_dir = 'D:\result_tests\WinPython-64bit-3.4.2.2_build2\tools\Julia\bin'
sysimg_relpath = '.\sys.ji'
sysimg_relpath_alt = '.\julia\sys.ji'
and so doesn't find 'sys.ji' at
D:\result_tests\WinPython-64bit-3.4.2.2_build2\python-3.4.2.amd64\..\tools\Julia\bin\.\sys.ji
D:\result_tests\WinPython-64bit-3.4.2.2_build2\python-3.4.2.amd64\..\tools\Julia\bin\.\julia\sys.ji
D:\result_tests\WinPython-64bit-3.4.2.2_build2\python-3.4.2.amd64\lib\site-packages\julia\core.py in __init__(self, init_julia, jl_init_path)
244 sysimg_relpath = sysimg_relpath_alt
245 else:
--> 246 raise JuliaError("Julia sysimage (\"sys.ji\") not found! {}".format(sysimg_relpath))
247
248 self.api = ctypes.PyDLL(libjulia_path, ctypes.RTLD_GLOBAL)
JuliaError: Julia sysimage ("sys.ji") not found! .\sys.ji
Please, what did I do wrong ?
Version 0.5.0 (2016-09-19 18:14 UTC)
julia> Pkg.add("ParallelAccelerator")
;
INFO: Installing CompilerTools v0.2.0
INFO: Installing DataStructures v0.4.6
INFO: Installing DocOpt v0.2.0
INFO: Installing ParallelAccelerator v0.2.1
INFO: Building ParallelAccelerator
ParallelAccelerator: build.jl begin.
ParallelAccelerator: Building j2c-array shared library
Using icpc to build ParallelAccelerator array runtime.
In file included from /usr/include/c++/6.2.1/set(60),
from include/j2c-array.h(41),
from j2c-array.cpp(26):
/usr/include/c++/6.2.1/bits/stl_tree.h(1437): error: identifier "_Compare" is undefined
&& is_nothrow_move_assignable<_Compare>::value)
^
In file included from /usr/include/c++/6.2.1/set(60),
from include/j2c-array.h(41),
from j2c-array.cpp(26):
/usr/include/c++/6.2.1/bits/stl_tree.h(1778): error: identifier "_Compare" is undefined
_GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
^
compilation aborted for j2c-array.cpp (code 2)
================================================[ ERROR: ParallelAccelerator ]================================================
LoadError: failed process: Process(./build.sh '' /opt/intel/composer_xe_2015.3.187/compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/mpirt/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/tools/intel64/perfsys:/opt/intel/composer_xe_2015.3.187/compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/mkl/lib/intel64:/opt/intel/composer_xe_2015.3.187/tbb/lib/intel64/gcc4.1:/opt/intel/composer_xe_2015.3.187/debugger/libipt/intel64/lib:/usr/lib64/openmpi/lib:/opt/intel/composer_xe_2015.3.187/compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/mpirt/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/lib/intel64:/opt/intel/composer_xe_2015.3.187/ipp/tools/intel64/perfsys:/opt/intel/composer_xe_2015.3.187/compiler/lib/intel64:/opt/intel/composer_xe_2015.3.187/mkl/lib/intel64:/opt/intel/composer_xe_2015.3.187/tbb/lib/intel64/gcc4.1:/opt/intel/composer_xe_2015.3.187/debugger/libipt/intel64/lib:/usr/lib64/openmpi/lib:
, ProcessExited(2)) [2]
while loading /home/user/.julia/v0.5/ParallelAccelerator/deps/build.jl, in expression starting on line 94
==============================================================================================================================
=======================================================[ BUILD ERRORS ]=======================================================
WARNING: ParallelAccelerator had build errors.
Pkg.build("ParallelAccelerator")
deps/build.jl
script==============================================================================================================================
INFO: Package database updated
Hi,
a simpler version of previous issue #35 , that demonstrates the problem with Python3.4:
import julia
j = julia.Julia()
%load_ext julia.magic
print(j.eval("sqrt(1 +31)"))
print(j.sind(90))
but
%load_ext julia.magic
import julia
j = julia.Julia()
print(j.eval("sqrt(1 +31)"))
print(j.sind(90))
I am getting the following exception when doing the tests or attempting to initialize julia with julia.Julia()
Steps performed to install on Ubuntu 14.04:
install julia version 0.3.11 via the ppa for release stable.
set up environment in PyCall with ENV["PYTHON"] = "/usr/bin/python3"
used Pkg.build("PyCall")
INFO: Building PyCall
INFO: PyCall is using /usr/bin/python3 (Python 3.4.3) at /usr/bin/python3, libpython = libpython3.4m
using PyCall
@pyimport math
math.sin(math.pi / 4) - sin(pi / 4) # returns 0.0
So PyCall works.
now with Python:
$/usr/bin/python3
>>>import julia
>>>julia.Julia()
Warning: error initializing module PyCall:
PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x0000000005da8240), val=PyCall.PyObject(o=0x0000000004d552b0), traceback=PyCall.PyObject(o=0x0000000004d574c8))
Traceback (most recent call last):
File "/home/user/libs/pyjulia/julia/core.py", line 289, in __init__
self.call('pyinitialize(C_NULL)')
File "/home/user/libs/pyjulia/julia/core.py", line 329, in call
.format(exception_type, exception_msg, src))
julia.core.JuliaError: Exception 'UndefVarError' ocurred while calling julia code:
<couldn't get stack>
Code:
pyinitialize(C_NULL)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/libs/pyjulia/julia/core.py", line 291, in __init__
raise JuliaError("Failed to initialize PyCall package")
julia.core.JuliaError: Failed to initialize PyCall package
I tried the same thing with Python2 with the same results.
Is there any way to exceute and entire Julia file using the pyjulia package?
Is it possible for python to capture print
from julia? So that STDOUT
from julia is fed to some python's OutStream
?
I'm getting the following error WindowsError: [Error 2] The system cannot find the file specified
while trying to run the basic examples on a fresh install.
Windows 10 Pro
Julio 0.5.0 64bit fresh install from the julia.org
Python 2.7
Latest install of PyCall
Latest git branch of pyjulia
In [1]: import julia
In [2]: j = julia.Julia()
---------------------------------------------------------------------------
WindowsError Traceback (most recent call last)
<ipython-input-2-f420be51b3fc> in <module>()
----> 1 j = julia.Julia()
C:\Users\npezolano\svn\git\pyjulia\julia\core.pyc in __init__(self, init_julia, jl_runtime_path, jl_init_path, debug)
269 println("nowhere")
270 end
--> 271 """])
272 JULIA_HOME, libjulia_path, depsjlexe = juliainfo.decode("utf-8").rstrip().split("\n")
273 exe_differs = not depsjlexe == sys.executable
C:\Anaconda\lib\subprocess.pyc in check_output(*popenargs, **kwargs)
564 if 'stdout' in kwargs:
565 raise ValueError('stdout argument not allowed, it will be overridden.')
--> 566 process = Popen(stdout=PIPE, *popenargs, **kwargs)
567 output, unused_err = process.communicate()
568 retcode = process.poll()
C:\Anaconda\lib\subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
708 p2cread, p2cwrite,
709 c2pread, c2pwrite,
--> 710 errread, errwrite)
711 except Exception:
712 # Preserve original exception in case os.close raises.
C:\Anaconda\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
956 env,
957 cwd,
--> 958 startupinfo)
959 except pywintypes.error, e:
960 # Translate pywintypes.error to WindowsError, which is
WindowsError: [Error 2] The system cannot find the file specified
@jakebolewski says that julia.foo<tab>
used to do completion. Would be nice if this still worked.
python -m unittest test.test_core
(from the travis file) gives:
Traceback (most recent call last):
File "/Users/stevenj/anaconda/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/stevenj/anaconda/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/stevenj/anaconda/lib/python2.7/unittest/__main__.py", line 12, in <module>
main(module=None)
File "/Users/stevenj/anaconda/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/Users/stevenj/anaconda/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/Users/stevenj/anaconda/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/Users/stevenj/anaconda/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/Users/stevenj/anaconda/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_core'
macstation004:pyjulia stevenj$
@jakebolewski, I don't really understand the Python module logic; can you fix?
@stevengj any ideas why that would be the case?
cc @ViralBShah
Using this machine I tend to run into problems with old compilers occasionally, so that may be the problem (which I do not have root access).
Here is my install error:
running install
running build
running build_py
running install_lib
byte-compiling /mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/init.py to init.pyc
File "/mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/init.py", line 1
from .core import Julia, JuliaError
^
SyntaxError: invalid syntax
byte-compiling /mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/core.py to core.pyc
File "/mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/core.py", line 362
boxed_obj = self.api.jl_get_field(void_p(res), b'o')
^
SyntaxError: invalid syntax
byte-compiling /mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/magic.py to magic.pyc
File "/mnt/data/dfagnan/local/lib/python2.4/site-packages/julia/magic.py", line 33
class JuliaMagics(Magics):
^
SyntaxError: invalid syntax
Version stuff:
Python 2.4.3 (#1, Oct 23 2012, 22:02:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Julia Version 0.3.3
Commit b24213b (2014-11-23 20:19 UTC)
Platform Info:
System: Linux (x86_64-redhat-linux6E)
CPU: Intel(R) Xeon(R) CPU X5570 @ 2.93GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3
Hey there,
Just want to say that I am of of the owner of the julia
name on the Python Packaging Index (aka PyPI) with @stevengj , if any of the owner here want to be added as a package maintainer or owner, I'll be happy to do it.
If you just need me to build the package and upload it I can do that as well.
Also while I'm at it, It woudl be interesting to put a dummy repo in https://github.com/JuliaInterop (PyCall.jl) that redirect to this organisation)
[This duplicates parts of the issues reported in #66 and its comments but should be fully reproducible.]
I have installed PyJulia in a fairly minimalistic docker build. Dockerfile:
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y python3 python3-dev python3-setuptools wget git bzip2
RUN cd /opt \
&& wget https://julialang.s3.amazonaws.com/bin/linux/x64/0.5/julia-0.5.0-linux-x86_64.tar.gz \
&& mkdir julia \
&& tar xvfz julia-0.5.0-linux-x86_64.tar.gz --strip-components 1 -C julia
ENV PATH /opt/julia/bin:$PATH
ENV PYTHON /usr/bin/python3
RUN julia -e 'Pkg.add("PyCall")'
RUN cd /opt \
&& git clone https://github.com/JuliaPy/pyjulia.git \
&& cd pyjulia \
&& python3 setup.py install
As far as I can tell it complies with the installation instructions in the README.
All the following examples are run in separate containers freshly started from the image specified above. Testing PyJulia right away gives a failure to locate fake-julia.
root@382813662d53:/# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> j = julia.Julia()
WARNING: redefining constant JULIA_HOME
could not spawn `/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/../fake-julia/julia -Cx86-64 -J/opt/julia/lib/julia/sys.so --compile=yes --depwarn=yes -O0 --output-ji /root/.julia/lib/pyjulia3-v0.5/PyCall.ji --output-incremental=yes --startup-file=no --history-file=no --color=no --eval 'while !eof(STDIN)
eval(Main, deserialize(STDIN))
end
'`: no such file or directory (ENOENT)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 353, in __init__
self._call(u"using PyCall")
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 392, in _call
self.check_exception(src)
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 412, in check_exception
.format(exception_type, src))
julia.core.JuliaError: Exception 'UVError' occurred while calling julia code:
using PyCall
>>>
root@382813662d53:/# ls /usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg
EGG-INFO julia
Doesn't look like fake-julia is installed. Should it be?
First forcing a precompile of PyCall apparently eliminates the need for fake-julia but instead crashes with a segmentation fault.
root@f34ebf9ca732:/# julia -e "using PyCall"
root@f34ebf9ca732:/# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> j = julia.Julia()
WARNING: redefining constant JULIA_HOME
InitError(:PyCall,PyError (:PyImport_ImportModule) <class 'SystemError'>
SystemError('initialization of _opcode did not return an extension module',)
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
PyObject_Call at /usr/lib/x86_64-linux-gnu/libpython3.5m.so (unknown line)
macro expansion at /root/.julia/v0.5/PyCall/src/exception.jl:78 [inlined]
#_pycall#62 at /root/.julia/v0.5/PyCall/src/PyCall.jl:546
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1392 [inlined]
jl_f__apply at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:547
_pycall at /root/.julia/v0.5/PyCall/src/PyCall.jl:534
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1392 [inlined]
jl_f__apply at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:547
#pycall#65 at /root/.julia/v0.5/PyCall/src/PyCall.jl:565
show at /root/.julia/v0.5/PyCall/src/exception.jl:39
unknown function (ip: 0x7f9cea309226)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
show_default at ./show.jl:130
unknown function (ip: 0x7f9cea307c26)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
show at ./show.jl:116
unknown function (ip: 0x7f9cea307686)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:189 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1942
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1392 [inlined]
jl_show at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:972
ffi_call_unix64 at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
ffi_call at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
_ctypes_callproc at /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7f9f0c52afca)
PyObject_Call at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
unknown function (ip: 0x52d2e2)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
PyEval_EvalCodeEx at python3 (unknown line)
unknown function (ip: 0x4ebd37)
PyObject_Call at python3 (unknown line)
unknown function (ip: 0x4f413d)
PyObject_Call at python3 (unknown line)
unknown function (ip: 0x54d358)
unknown function (ip: 0x55d17b)
PyObject_Call at python3 (unknown line)
PyEval_EvalFrameEx at python3 (unknown line)
unknown function (ip: 0x52d2e2)
PyEval_EvalCode at python3 (unknown line)
unknown function (ip: 0x5fd2c1)
PyRun_InteractiveOneObject at python3 (unknown line)
PyRun_InteractiveLoopFlags at python3 (unknown line)
unknown function (ip: 0x4585cf)
unknown function (ip: 0x4cf269)
main at python3 (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at python3 (unknown line)
Allocations: 2218551 (Pool: 2217599; Big: 952); GC: 1
Segmentation fault (core dumped)
Adding a rebuild of PyCall takes us back to the first failure.
root@c330a94202e3:/# julia -e 'using PyCall; Pkg.build("PyCall")'
INFO: Building Conda
INFO: Building PyCall
INFO: PyCall is using /usr/bin/python3 (Python 3.5.2) at /usr/bin/python3, libpython = libpython3.5m
root@c330a94202e3:/# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> j = julia.Julia()
WARNING: redefining constant JULIA_HOME
could not spawn `/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/../fake-julia/julia -Cx86-64 -J/opt/julia/lib/julia/sys.so --compile=yes --depwarn=yes -O0 --output-ji /root/.julia/lib/pyjulia3-v0.5/PyCall.ji --output-incremental=yes --startup-file=no --history-file=no --color=no --eval 'while !eof(STDIN)
eval(Main, deserialize(STDIN))
end
'`: no such file or directory (ENOENT)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 353, in __init__
self._call(u"using PyCall")
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 392, in _call
self.check_exception(src)
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 412, in check_exception
.format(exception_type, src))
julia.core.JuliaError: Exception 'UVError' occurred while calling julia code:
using PyCall
For what it's worth, copying fake-julia into the installed egg does at least allow basic usage to work, although the JULIA_HOME warning is still there.
root@c98507fe7aef:/# cp -r /opt/pyjulia/fake-julia /usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg
root@c98507fe7aef:/# python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> j = julia.Julia()
WARNING: redefining constant JULIA_HOME
>>> j.sind(90)
1.0
If you want to exactly replicate, use amazon ec2, image ami-9a562df2 (aka the official ubuntu 14.04 image), machine m3.medium, solid-state drive, provisioned with docker by vagrant. Then build this Dockerfile:
FROM ipython/scipyserver
# install julia from the approved ppa, and get pycall
RUN apt-get install -y software-properties-common python-software-properties \
&& add-apt-repository -y ppa:staticfloat/juliareleases \
&& apt-get update \
&& apt-get install -y julia \
&& julia -e 'Pkg.resolve(); Pkg.update(); Pkg.add("PyCall")'
# install pyjulia
RUN git clone https://github.com/JuliaLang/pyjulia.git \
&& pip3 install ./pyjulia
# run it, and wait. a long time :).
CMD python3 -c "import julia,time,sys; print('starting!'); sys.stdout.flush(); t=time.time(); j=julia.Julia(); print(time.time()-t); print('done')"
Running the resulting docker image should yield results like this:
ubuntu@ip-172-30-4-223:~$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
soslow latest 61ba5988405a 13 minutes ago 2.874 GB
ipython/scipyserver latest 9a23ce264f79 12 hours ago 2.651 GB
ubuntu@ip-172-30-4-223:~$ docker run --rm soslow
starting!
403.7160954475403
done
ubuntu@ip-172-30-4-223:~$ docker run --rm soslow
starting!
401.85526943206787
done
ubuntu@ip-172-30-4-223:~$ docker run --rm soslow
starting!
403.40179347991943
done
While it is running, the command is using 100% of the cpu.
I experience the same phenomena working from the base image library/python, so I don't think it's that.
I experience the same phenomena if I install pip3 on the ec2 machine and then use those Dockerfile instructions to directly provision the ec2 machine (without using docker). That is,
ubuntu@ip-172-30-4-223:~$ python3 -c "import julia,time,sys; print('starting'); sys.stdout.flush(); t=time.time(); j=julia.Julia(); print(time.time()-t); print('done')"
starting
402.0854015350342
done
I experience the same phenomena running python2.7 instead of python3.4.
Every once and while, it is modestly reasonable (20 seconds). But then it goes back to being very slow. The behavior appears random, which is very disturbing :).
Why is nobody else experiencing this?? I must be doing something dreadfully wrong!
It seems like all 1d lists in python are converted to Array{Any,1}
. Can we get tighter types?
I'm willing to hack this a bit, where does this transformation take place in the code?
python 3.5.1
Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
In [11]: j.call("using Clustering")
WARNING: call(f,args...) is deprecated, use f(args...) instead.
in ##979#980(::Array{Any,1}, ::Function, ::String) at ./deprecated.jl:271
in (::Base.##979#981)(::String) at ./deprecated.jl:270
in jl_Function_call(::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}) at /home/nbecker/.julia/v0.5/PyCall/src/callback.jl:35
RuntimeError Traceback (most recent call last)
in ()
----> 1 j.call("using Clustering")
RuntimeError: Julia exception: MethodError("using Clustering",())
>>> import julia
>>> j = julia.Julia()
ERROR: UndefVarError: dlpath not defined
in eval(::Module, ::Any) at ./boot.jl:234
in eval(::Module, ::Any) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
in process_options(::Base.JLOptions) at ./client.jl:239
in _start() at ./client.jl:318
in _start() at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/<username>/anaconda/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
it works if I start python from pyjulia root dir
cd path/to/pyjulia
python
>>> import julia
>>> j = julia.Julia()
>>>
I'm trying to use the FIRFilter type, from the julia DSP module, from python
This doesn't seem to work, I believe because
j = julia.Julia()
j.using('DSP')
adds all functions from DSP, but not types. I conclude that by adding a print within core.py::add_module_functions, and I see lots of functions added, but not FIRFilter
karan@karan:~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> jl = julia.Julia()
WARNING: redefining constant JULIA_HOME
could not spawn `/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/../fake-julia/julia -Cx86-64 -J/home/karan/Downloads/julia-3c9d75391c/lib/julia/sys.so --compile=yes --depwarn=yes -O0 --output-ji /home/karan/.julia/lib/pyjulia3-v0.5/PyCall.ji --output-incremental=yes --startup-file=no --history-file=no --color=no --eval 'while !eof(STDIN)
eval(Main, deserialize(STDIN))
end
'`: no such file or directory (ENOENT)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 353, in __init__
self._call(u"using PyCall")
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 392, in _call
self.check_exception(src)
File "/usr/local/lib/python3.5/dist-packages/julia-0.1.1-py3.5.egg/julia/core.py", line 412, in check_exception
.format(exception_type, src))
julia.core.JuliaError: Exception 'UVError' occurred while calling julia code:
using PyCall
>>>
hi,
Python2.7 has a problem with IPython3.0rc1 windows32bit:
import julia
j = julia.Julia()
%load_ext julia.magic
Jupyter Notebook
Using python julia module (autosaved)
Python 2
File
Edit
View
Insert
Cell
Kernel
Help
Cell Toolbar:
In [1]:
%matplotlib inline
In [2]:
# Waking up Julia takes up to 40 seconds the first time
import julia
j = julia.Julia()
In [3]:
print(j.eval("sqrt(1 +31)"))
print(j.sind(90))
5.65685424949
1.0
In [7]:
%load_ext julia.magic
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-5bcfdab8fb0a> in <module>()
----> 1 get_ipython().magic(u'load_ext julia.magic')
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\interactiveshell.pyc in magic(self, arg_s)
2302 magic_name, _, magic_arg_s = arg_s.partition(' ')
2303 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2304 return self.run_line_magic(magic_name, magic_arg_s)
2305
2306 #-------------------------------------------------------------------------
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\interactiveshell.pyc in run_line_magic(self, magic_name, line)
2223 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2224 with self.builtin_trap:
-> 2225 result = fn(*args,**kwargs)
2226 return result
2227
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\magics\extension.pyc in load_ext(self, module_str)
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\magics\extension.pyc in load_ext(self, module_str)
61 if not module_str:
62 raise UsageError('Missing module name.')
---> 63 res = self.shell.extension_manager.load_extension(module_str)
64
65 if res == 'already loaded':
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\IPython\core\extensions.pyc in load_extension(self, module_str)
83 if module_str not in sys.modules:
84 with prepended_to_syspath(self.ipython_extension_dir):
---> 85 __import__(module_str)
86 mod = sys.modules[module_str]
87 if self._call_load_ipython_extension(mod):
D:\WinPython\basedir27\buildFlavorJulia\winpython-2.7.9\python-2.7.9\lib\site-packages\julia\core.pyc in load_module(self, fullname)
106 return getattr(self.julia, juliapath)
107 else:
--> 108 raise ImportError("{} not found".format(juliapath))
109
110
ImportError: magic not found
the same three are working ok with Python3.4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.