OpenCV didn't work in Python virtual env on Archlinux

Viewed 77

I have installed opencv by the follow commands:

sudo pacman -Sy opencv python-opencv hdf5 vtk

After this, I can use opencv normally in the system python and C++ environment, but opencv didn't work when I create a new virtual environment.

I installed opencv-python and numpy by pip , and I tried to run a sample program using python in a virtual environment:

import cv2

img = cv2.imread("./001.jpg")
cv2.imshow("outuput", img)
cv2.waitKey(0)

it tells me:

segmentation fault (core dumped)

if I run this demo without using a virtual environment, everything is normal, and the image will be output normally.

But I didn't install the pip package opencv-python in system python environment.

I want to know how opencv works with python ? and how to make it work in a virtual environment?

0 Answers
Related