Linking Julia to different Anaconda virtual environments
161 views
Skip to first unread message
John Hammonds
unread,
Aug 19, 2016, 7:53:47 PM8/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia-users
I have been using Anaconda Python with their virtual environments. I am starting to look into Julia and would like to be able to use PyCall to call in python code. I am using the virtual environments to manage different projects/versions. My Base Python is fairly minimal, I install most packages in the virtenvs, When I use PyCall and @pyimport, I seem to only find packages in my base anaconda installation. Is there a clean way to switch between different virtual environments when I am using Julia?
Scott T
unread,
Aug 19, 2016, 10:13:01 PM8/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia-users
Hi John,
Because PyCall links directly to the Python libraries, you have to rebuild it every time you want to use a different version of Python. That includes switching virtual environments. You do this by setting the environment variable PYTHON (ENV["PYTHON"] from within Julia) to the location of the python executable and then running Pkg.build("PyCall"). The process is pretty quick so you could probably write a function in your .juliarc.jl file to let you switch between environments. I haven't done this yet because I just use the root conda environment, but it's what I would do if I needed to switch between several.