Julia: How to Use Conda Virtual Environments in PyCall

Hongtao Hao / 2021-11-03


The following solution is based on this discussion .

Suppose you are using a Mac. Open your Terminal and use the following codes:

julia 
ENV["PYTHON"] = "/opt/anaconda3/envs/ENVNAME/bin/python3.8"
import Pkg
Pkg.build("PyCall")

Replace ENVNAME with the name of your virtual environment.

Then you can use PyCall. If you are using IJulia, you need to restart it before you can use PyCall.

Last modified on 2021-11-27