JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 190 forks source link

segfault when testing PyCall, error initializing PyPlot, julia release 3.10 Ubuntu binaries, 3.11 compiled from source on Ubuntu #170

Open rieser opened 9 years ago

rieser commented 9 years ago

I'm getting a segfault when calling Pkg.test("PyCall"). 'using PyCall' then gives no error, but 'using PyPlot' doesn't work. The output of the two problematic functions and versioninfo is below. This happened both on the Ubuntu binaries (julia release 3.10) and after compiling from source on Ubuntu (julia release 3.11). The output below is from the Ubuntu binaries. The output from the version compiled from source is similar.

Many thanks for your help!

Julia Version 0.3.10 Commit c8ceeef (2015-06-24 13:54 UTC) Platform Info: System: Linux (x86_64-linux-gnu) CPU: Intel(R) Xeon(R) CPU E5420 @ 2.50GHz WORD_SIZE: 64 BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Penryn) LAPACK: liblapack.so.3 LIBM: libopenlibm LLVM: libLLVM-3.3

julia> using PyPlot Warning: error initializing module PyPlot: PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x00000000339078a0), val=PyCall.PyObject(o=0x00000000351631b8), traceback=PyCall.PyObject(o=0x0000000000000000))

julia> Pkg.test("PyCall") INFO: Testing PyCall

signal (11): Segmentation fault PyObject_IsInstance at /usr/lib/x86_64-linux-gnu/libpython2.7.so (unknown line) pyisinstance at /home/tony/.julia/v0.3/PyCall/src/PyCall.jl:81 jlcall_pyisinstance_20478 at (unknown line) jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) pyptr_query at /home/tony/.julia/v0.3/PyCall/src/conversions.jl:152 pytype_query at /home/tony/.julia/v0.3/PyCall/src/conversions.jl:794 convert at /home/tony/.julia/v0.3/PyCall/src/conversions.jl:844 roundtripeq at /home/tony/.julia/v0.3/PyCall/test/runtests.jl:6 jlcall_roundtripeq_20810 at (unknown line) jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) anonymous at test.jl:62 do_test at test.jl:37 jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) unknown function (ip: 1196219800) unknown function (ip: 1196215936) unknown function (ip: 1196283418) unknown function (ip: 1196286125) jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) include at ./boot.jl:245 jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) include_from_node1 at loading.jl:128 jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) process_options at ./client.jl:285 _start at ./client.jl:354 jlcall__start_17415 at /usr/bin/../lib/x86_64-linux-gnu/julia/sys.so (unknown line) jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) unknown function (ip: 4200623) julia_trampoline at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line) unknown function (ip: 4199613) __libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) unknown function (ip: 4199667) unknown function (ip: 0) ================================================================================================================================[ ERROR: PyCall ]=================================================================================================================================

failed process: Process(/usr/bin/julia /home/tony/.julia/v0.3/PyCall/test/runtests.jl, ProcessSignaled(11)) [0]

INFO: No packages to install, update or remove ERROR: PyCall had test errors in error at error.jl:21 in test at pkg/entry.jl:718 in anonymous at pkg/dir.jl:28 in cd at ./file.jl:20 in cd at pkg/dir.jl:28 in test at pkg.jl:67

stevengj commented 9 years ago

Can you try Pkg.checkout("PyCall"); Pkg.update(); Pkg.build("PyCall"); Pkg.test("PyCall")?

rieser commented 9 years ago

Hi,

Thanks for your message. When I do what you suggested, I get the following error (in both versions):

julia> Pkg.test("PyCall") INFO: Testing PyCall Warning: error initializing module PyCall: MemoryError() ERROR: test failed: roundtripeq(nothing) in error at error.jl:21 in default_handler at test.jl:19 in do_test at test.jl:39 in include at ./boot.jl:245 in include_from_node1 at loading.jl:128 in process_options at ./client.jl:285 in _start at ./client.jl:354 while loading /home/tony/.julia/v0.3/PyCall/test/runtests.jl, in expression starting on line 23 ===============================[ ERROR: PyCall ]================================

failed process: Process(/home/tony/julia/usr/bin/julia /home/tony/.julia/v0.3/PyCall/test/runtests.jl, ProcessExited(1)) [1]

INFO: No packages to install, update or remove ERROR: PyCall had test errors in error at error.jl:21 in test at pkg/entry.jl:718 in anonymous at pkg/dir.jl:28 in cd at ./file.jl:20 in cd at pkg/dir.jl:28 in test at pkg.jl:67

Cheers,

Antonio

On 23 July 2015 at 19:03, Steven G. Johnson notifications@github.com wrote:

Can you try Pkg.checkout("PyCall"); Pkg.update(); Pkg.build("PyCall"); Pkg.test("PyCall")?

— Reply to this email directly or view it on GitHub https://github.com/stevengj/PyCall.jl/issues/170#issuecomment-124152252.

stevengj commented 9 years ago

What Python distro are you using? (What is the output of print(readall(joinpath(Pkg.dir("PyCall"),"deps","deps.jl"))), i.e. the contents of PyCall/deps/deps.jl?)

rieser commented 9 years ago

Here it is:

const python = "python" const libpython = "libpython2.7" const pyprogramname = bytestring("/usr/local/bin/python") const pyversion_build = v"2.7.6"

const PYTHONHOME = "/usr/local:/usr/local"

const PyUnicode_AsUTF8String = :PyUnicodeUCS4_AsUTF8String const PyUnicode_DecodeUTF8 = :PyUnicodeUCS4_DecodeUTF8

const PyString_FromString = :PyString_FromString const PyString_AsString = :PyString_AsString const PyString_Size = :PyString_Size const PyString_Type = :PyString_Type const PyInt_Type = :PyInt_Type const PyInt_FromSize_t = :PyInt_FromSize_t const PyInt_FromSsize_t = :PyInt_FromSsize_t const PyInt_AsSsize_t = :PyInt_AsSsize_t

const Py_hash_t = Int64

const pyunicode_literals = false

On 27 July 2015 at 22:57, Steven G. Johnson notifications@github.com wrote:

What Python distro are you using? (What is the output of print(readall(joinpath(Pkg.dir("PyCall"),"deps","deps.jl"))), i.e. the contents of PyCall/deps/deps.jl?)

— Reply to this email directly or view it on GitHub https://github.com/stevengj/PyCall.jl/issues/170#issuecomment-125326047.

tahenti commented 9 years ago

Hi

I have a problem with PyPlot. I think that i am not using the conda distribution of Python. if i make the same command that is my out put :

const python = "/usr/bin/python" const libpython = "libpython2.7" const pyprogramname = bytestring("/usr/bin/python") const pyversion_build = v"2.7.6" const PYTHONHOME = bytestring("/usr:/usr")

"True if we are using the Python distribution in the Conda package." const conda = false

const PyUnicode_AsUTF8String = :PyUnicodeUCS4_AsUTF8String const PyUnicode_DecodeUTF8 = :PyUnicodeUCS4_DecodeUTF8

const PyString_FromString = :PyString_FromString const PyString_AsString = :PyString_AsString const PyString_Size = :PyString_Size const PyString_Type = :PyString_Type const PyInt_Type = :PyInt_Type const PyInt_FromSize_t = :PyInt_FromSize_t const PyInt_FromSsize_t = :PyInt_FromSsize_t const PyInt_AsSsize_t = :PyInt_AsSsize_t

const Py_hash_t = Int64

const pyunicode_literals = false

thanks for your help.

stevengj commented 9 years ago

As a workaround, you could try:

ENV["PYTHON"]=""
Pkg.build("PyCall")

(you only need to do this once) to use the Conda python distro.

stevengj commented 9 years ago

Can you try Julia 0.4?

tahenti commented 9 years ago

I'am using Julia 0.4. And i did the two command but it doesn't delete the error. That is what i get when i try to execute a code with PyPlot. INFO: Installing matplotlib via the Conda package... Fetching package metadata: .... Solving package specifications: ......................

All requested packages already installed.

packages in environment at /root/.julia/v0.4/Conda/deps/usr:

# matplotlib 1.4.3 np110py27_2
ERROR: LoadError: InitError: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'> ImportError('cannot import name scimath',) File "/root/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/init.py", line 180, in from matplotlib.cbook import is_string_like File "/root/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in import numpy as np File "/root/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/init.py", line 180, in from . import add_newdocs File "/root/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in from numpy.lib import add_newdoc File "/root/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/lib/init.py", line 17, in from . import scimath as emath

[inlined code] from /root/.julia/v0.4/PyCall/src/exception.jl:81 in pyimport at /root/.julia/v0.4/PyCall/src/PyCall.jl:79 in init at /root/.julia/v0.4/PyPlot/src/PyPlot.jl:227 in _require_from_serialized at loading.jl:84 in _require_from_serialized at ./loading.jl:109 in require at ./loading.jl:219 in include at ./boot.jl:261 in include_from_node1 at ./loading.jl:304 during initialization of module PyPlot while loading /home/beya/Lenom Simulation/MBrownian.jl, in expression starting on line 10

stevengj commented 9 years ago

The cannot import name scimath sounds like #65, which is fixed in Julia 0.4 .... but it will fail if you have a libopenblas.so from Julia 0.3 lying around, as explained in #65. You'll need to delete any libopenblas.so you installed from Julia 0.3 for it to work in 0.4.