If you have read my earlier posts you know I love multilingual programming. One important part of multilingual programming is how to interface one language with other. Typically this is called FFI or foreign function interface. At the lowest level often there are libraries (aka bindings) to talk across languages or across implementations of same language e.g. libffi. In my undergrad we did a group project where we created language bindings to separate algorithmic part written in python and opencv and X11 logic in c.
Recently I have started learning Julia which promises programmer productivity of Python and performance of C*. Julia PyCall library provides FFI for Python. After multiple unsuccessful attempts to use PyCall on Windows, I found out one needs to set PYTHONPATH
environment variable in addition to PYTHON
environment variable in Julia script to use specific python virtual environment. PyCall can automatically install conda and packages from conda but seems like if one wishes to use virtualenvironment and pip one needs to set these environment variables manually in the Julia script.
ENV["PYTHON"] = raw"<pathToVirtualEnv>\Scripts\python.exe"
ENV["PYTHON"] = raw"<pathToVirtualEnv>\lib\site-packages"
# Note the `raw` string literal in Julia which eliminates
# need of escaping `\` in Windows paths.
Hope you find it useful.
✌
Top comments (0)