LoadError:PyCall.PyError

I am getting the following Error for PyCall and am on Julia v 1.2.0 Following is the Python setup and the Conda setup in build file

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

using PyCall, Conda
pyexec = pyimport("sys").executable
ERROR: LoadError: PyCall.PyError("\$(Expr(:escape, :(ccall(#= /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f9ea56a2520), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f9db65dcca8), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f9d004f9f08))
Stacktrace:
 [1] pyerr_check at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:60 [inlined]
 [2] pyerr_check at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:64 [inlined]
 [3] macro expansion at /home/omkar/.julia/packages/PyCall/ttONZ/src/exception.jl:84 [inlined]
 [4] __pycall!(::PyCall.PyObject, ::Ptr{PyCall.PyObject_struct}, ::PyCall.PyObject, ::Ptr{Nothing}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:44
 [5] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{String,String,String,String,String,Float64,String,Float64}, ::Int64, ::Ptr{Nothing}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:29
 [6] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{String,String,String,String,String,Float64,String,Float64}, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:11
 [7] #call#111(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::PyCall.PyObject, ::String, ::Vararg{Any,N} where N) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89
 [8] (::PyCall.PyObject)(::String, ::Vararg{Any,N} where N) at /home/omkar/.julia/packages/PyCall/ttONZ/src/pyfncall.jl:89

1 Like

I’m not sure if it matters, but I believe the recommendation is to set ENV["PYTHON"] to "" (an empty string), while you are setting it to " " (a string containing a single space). Does changing that have any effect?

1 Like

Is it the full stacktrace? Also, you’d probably want to evaluate pysys = pyimport("sys") and pysys.executable separately to see when it fails.

It is set to an empty string in the build.It does not solve the Error.

There are two more lines which have the confidential code file names. But those just mention the type of data structure in that function call.

I can’t reproduce your problem. What operating system are you using? Is your PyCall installation up-to-date? (e.g. you haven’t pinned anything at old versions if you run st at the pkg> prompt?)

Note that you need to start a new Julia session when you re-run Pkg.build("PyCall") (which you normally only do once).

I have the same problem and my advisor told me that I need the xlrd package of Python. How can I get the package into Julia?

The “same problem” as in the same error message? Or an unrelated error message, e.g. because you didn’t install xlrd. (pyimport("xlrd") should work fine if xlrd is installed in the Python Julia is using, e.g. via using Conda; Conda.add("xlrd").)

In general, please don’t resurrect old threads with vaguely related questions… open a new thread if needed.

Note that Julia has several packages for reading Excel documents already, which are probably more friendly than calling Python: How to read excel into Julia? - Stack Overflow

1 Like