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

**URL:** <https://discourse.julialang.org/t/call-a-python-function-under-a-virtual-environment-use-a-returned-python-object-from-julia/20534>\
**Category:** General Usage\
**Created:** [February 7, 2019, 8:12am UTC](https://discourse.julialang.org/t/call-a-python-function-under-a-virtual-environment-use-a-returned-python-object-from-julia/20534 "2019-02-07T08:12:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [February 7, 2019, 8:12am UTC](https://discourse.julialang.org/t/call-a-python-function-under-a-virtual-environment-use-a-returned-python-object-from-julia/20534/1 "2019-02-07T08:12:33Z")

</div>

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:

> [@How to load and call functions defined in a standalone Python script?](https://discourse.julialang.org/t/how-to-load-and-call-functions-defined-in-a-standalone-python-script/601/3):
>
> Thank you @yuyichao, I will give the solution a try. slight_smile

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

```julia
 _/ |\ __'_|_|_|\__'_| | 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?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 7, 2019, 12:28pm UTC](https://discourse.julialang.org/t/call-a-python-function-under-a-virtual-environment-use-a-returned-python-object-from-julia/20534/2 "2019-02-07T12:28:11Z")

</div>

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"`.
