Top/article/Import-a-different-version-of-OpenCV-in-Python
English | Japanese
English | Japanese

Menu

  • Top
  • Akihiko Yamaguchi 山口 明彦
  • Project プロジェクト
  • Text テキスト
  • Recent articles 最近の記事
  • Articles 記事一覧 (a to z)
  • Search 検索

Tags タグ †

  • [c++][bash][python][latex][php]
  • [linux][windows][mac][android]
  • [math][algorithm][idea][trick]
  • [liboctave][opencv][git][ros]
  • [setting][bug][general]
↑

Recent articles 最近の記事 †

2019-07-02
  • article/Display-Unix-Time
  • article/Synchronize-Linux-Time-to-Remote
2018-09-27
  • article/python-multimode-singleton
2018-09-02
  • article/rosinstall-git-default-remote
2017-07-28
  • article/SubMenu
2017-03-05
  • article/Import-a-different-version-of-OpenCV-in-Python
2015-08-17
  • article/DRC-finals-2015
2015-01-05
  • article/Upgrade-Android-to-Lollipop
2015-01-01
  • article/Kernel-panic-of-Linux-when-using-Xtion
  • article/Do-not-skip-freeing-data-when-using-tri-mesh-in-ODE
Access: 1/2455 - Admin

Import a different version of OpenCV in Python

Pythonで異なるバージョンのOpenCVをimportするには

[python]
2017-03-05

When there are two versions of (e.g. OpenCV) libraries in a system, how to specify the imported version in Python?

ひとつのシステムに複数バージョンの(OpenCVなどの)ライブラリがインストールされているとき,Pythonから特定のバージョンをimportするにはどうすればいいのか.

The search paths of imported libraries are defined as the variable sys.path which is a list type. Modifying this variable, we can add/remove a search path. The order of search is from the beginning of sys.path. If we add a path by sys.path.append(...), it has a lowest priority. Thus we need to add a path in front of the list.

ライブラリの検索パスは sys.path 変数(リスト)定義されている.この変数に値を追加削除することで,検索パスを変更できる.検索の順番は sys.path の始めからである.つまりパスを sys.path.append(...) で追加すると,そのパスは最も優先度が低い.そこでリストの先頭にパスを加える必要がある.

e.g. 例

import sys
sys.path= ['/home/user/.local/lib/python2.7/dist-packages/']+sys.path
import cv2



Last-modified:2017-03-05 (Sun) 20:47:52 (2208d)
Site admin: Akihiko Yamaguchi.
Written by: Akihiko Yamaguchi.
System: PukiWiki 1.5.0. PHP 5.2.17. HTML conversion time: 0.010 sec.