Multiple Conda Environments + PyCall.jl?

I have been using PyCall.jl to wrap some algorithms written in Python to compare against a series of algorithms I’ve written in Julia.

I’ve started adding additional algorithms one of which is implemented ~4 years ago and is currently only available in Python 2. Instead of porting the code over to Python 3 I am calling methods from this code by using a PyCall environment built against a conda environment using Python 2: GitHub - JuliaPy/PyCall.jl: Package to call Python functions from the Julia language. Then, when I want to run other algorithms that are currently written in Python 3 I need to"PyCall") after pointing to my standard my standard Python 3 conda environment for that code.

I was wondering if there a better/more-robust solution?


I’m also looking for a way without running“PyCall”) to dynamically change the python environment during julia’s runtime.
If I find something, I’ll share it with you.

FYI my package PythonCall.jl allows you to use different Python installations without rebuilding but still only one installation per Julia session.

If you need to interface with old Python 2 code you’re probably best off running it in a subprocess.

1 Like