3

I want to use OpenCV on Julia, then I tried to use PyCall.
I made my Python environment by pyenv, therefore, I tried below commands;

julia> ENV["PYTHON"] = "/Users/MYNAME/.pyenv/shims/python"
julia> using Pkg
julia> Pkg.add("PyCall")

Then, I tried a below command and this error message was returned.

julia> using PyCall
ImportError: No module named site

This error message is too short to infer causes. Anyone knows the causes and how to solve?

  • what about using official bindings? https://docs.opencv.org/master/d8/da4/tutorial_julia.html – Miki Oct 20 '20 at 11:05

2 Answers2

2

PyCall is tested with Anaconda and it works best with the Anaconda installation inbuilt into Julia.

using Pkg
#ENV["PYTHON"] = ""
pkg"add PyCall"
#pkg"build PyCall"   #required to restore the default config if you changed it
pkg"add Conda"
using Conda
Conda.runconda(`install -c conda-forge opencv`)
using PyCall
const cv = pyimport("cv2")

Now you are ready to do your work.

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
1

There are also Julia bindings for OpenCV, although they haven't been integrated with Julia's artifact system and so still require a certain amount of manual effort to install. To get started, see this blog post.

tholy
  • 11,882
  • 1
  • 29
  • 42