Call a python function (under a virtual environment) (use a returned python object) from julia


#1

I was thinking to use a returned python object from the other python script, in my main julia package. I’m using Atom. I searched from the internet and found the following link:


So I tried it out in the REPL of Julia.
The following is the code.

 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> using PyCall

julia> push!(pyimport("sys")["/home/devel/Desktop/test.py"],pwd())
ERROR: KeyError: key "/home/devel/Desktop/test.py" not found
Stacktrace:
 [1] getindex(::PyObject, ::String) at /home/devel/.julia/packages/PyCall/0jMpb/src/PyCall.jl:289
 [2] top-level scope at none:0

But the file is there indeed.

Can anyone please let me know?


#2

Do push!(pyimport("sys")["path"], "/home/devel/Desktop") … you want the explicit string "path" here, because you are modifying sys.path to add a directory "/home/devel/Desktop".