Workaround memo when Segmentation fault: 11 appears in import of opencv that was brew installed with virtualenv of python

Reference: Using OpenCV with Python @Mac --Qiita

According to the above, under site-packages of my virtualenv, cv.py and cv2.so I put a symbolic link, but when I ʻimport cv`, ** "Segmentation fault: 11" ** came out and fell. UU….

In virtualenv,

After doing brew uninstall opencv I did brew install opencv

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getusersitepackages'

The error is.

I didn't feel like I could go straight, so I went to ~ / .bashrc.

# python
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:~/.virtualenvs/my_venv/lib/python2.7/site-packages:$PYTHONPATH

After adding and doing brew install opencv again, this time the above error did not appear.

Launch python with source ~ / .bashrc

import cv
import cv2

After that, there was no segfault. It was a memo. .. ..

(For the time being, anyenv → talk under the environment of pyenv)

If it still doesn't work

ʻEcho'import site; site.addsitedir ("/ usr / local / lib / python2.7 / site-packages ")' >> ~ / .pyenv / versions / {virtualenv_name} /lib/python2.7/site-packages Try /homebrew.pth` (No, maybe you should do it from the beginning).

Recommended Posts

Workaround memo when Segmentation fault: 11 appears in import of opencv that was brew installed with virtualenv of python
A memo when face is detected with Python + OpenCV quickly
When I tried to scrape using requests in python, I was addicted to SSLError, so a workaround memo
Import vtk with brew python
Here's a summary of things that might be useful when dealing with complex numbers in Python
A memo for when pip3 is installed with python2.7 for some reason
About bit full search that often appears in competition pros From the eyes of beginners with python
Working with LibreOffice in Python: import
Use rospy with virtualenv in Python3
Use OpenCV with Python 3 in Window
Graph Based Segmentation with Python + OpenCV
When using MeCab with virtualenv python
Basic study of OpenCV with Python
Get a list of packages installed in your current environment with python