PyCall.jl icon indicating copy to clipboard operation
PyCall.jl copied to clipboard

Issue pointing Pycall to Virtualenv

Open r-b0 opened this issue 5 years ago • 2 comments

I have a python 3.8 environment named myenv created using virtualenv that I am attempting to use with PyCall. The instructions in the readme to interface PyCall with virtual environments is yielding unexpected behaviour.

  • https://github.com/JuliaPy/PyCall.jl#python-virtual-environments

The issue is as follows -

Suppose myenv is installed at /home/myenv. All the python executables in /home/myenv/bin are symbolically linked to /usr/bin.

Following instructions in the readme, I activated myenv, opened the julia repl, and attempted to point PyCall to myenv via ENV["PYCALL_JL_RUNTIME_PYTHON"] = /home/myenv/bin/Python3.8

Unfortunately after issuing using PyCall, issuing pyimport("sys").executable returns /home/myenv/bin/Python3.8. Thus PyCall fails when attempting to import packages installed only in myenv.

Anyone have any idea why PyCall is not pointed to myenv after following the readme instructions? If I were a betting man, I'd bet something with the symlink is causing issue.

I am using Python3.8, Julia 1.3.1 on linux.

r-b0 avatar Dec 07 '20 06:12 r-b0

Was able to get this functional using the --always-copy option when creating a new virtualenv. Would anyone be opposed to adding a note about this in the readme?

It is indeed obvious in retrospect but I burned a bit of time on this in the moment.

r-b0 avatar Dec 07 '20 06:12 r-b0

I can confirm the same problem on Julia 1.6.1 as well. Strangely, I also get this:

julia> ENV["PYCALL_JL_RUNTIME_PYTHON"] = Sys.which("python")
"C:\\var\\venv\\Scripts\\python.exe"
julia> using PyCall
julia> pyimport("sys").executable
"C:\\Users\\...\\AppData\\Local\\Programs\\Julia-1.6.1\\bin\\julia.exe"

ghost avatar May 07 '21 14:05 ghost