4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HoudiniのPythonにモジュールを追加する方法

Posted at

HoudiniのPython(2系)にモジュールを追加する方法

Houdiniで最初から使えるモジュールの中に画像処理などでよく使うOpenCVなどはない。
image001.png

この様に「その様なモジュールは無い」というエラーが出る。
そこでHoudiniのPythonにOpenCVのモジュールを追加する方法を紹介する。

まず pip をインストールする
image.png
Side Effects SoftwareCommand Line Tools を管理者権限で実行

get-pip.py を落としてきて
D:\直下などに保存したとする。

python.exe D:\get-pip.py

と入力すると

C:\Program Files\Side Effects Software\Houdini 18.5.514\python27>python.exe D:\get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |################################| 1.5 MB 6.8 MB/s
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
  WARNING: The scripts pip.exe, pip2.7.exe and pip2.exe are installed in 'C:\Program Files\Side Effects Software\Houdini 18.5.514\python27\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script wheel.exe is installed in 'C:\Program Files\Side Effects Software\Houdini 18.5.514\python27\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.3.4 wheel-0.36.2

C:\Program Files\Side Effects Software\Houdini 18.5.514\python27>

実際の画面はこの様になる
image.png

これで pip がインストール出来た。
pip のインストールは一度で良い。

次にインストールしたいモジュールをインストールする。
例えばOpenCVなどをインストールしたい場合

python.exe -m pip install opencv-contrib-python

とすると

C:\Program Files\Side Effects Software\Houdini 18.5.514\python27>python.exe -m pip install opencv-contrib-python
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting opencv-contrib-python
  Downloading opencv_contrib_python-4.2.0.32-cp27-cp27m-win_amd64.whl (39.5 MB)
     |################################| 39.5 MB 8.5 MB/s
Requirement already satisfied: numpy>=1.11.1 in c:\program files\side effects software\houdini 18.5.514\python27\lib\site-packages (from opencv-contrib-python) (1.14.6)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.2.0.32

C:\Program Files\Side Effects Software\Houdini 18.5.514\python27>

この様に表示されcv2モジュールがHoudiniのPythonの中から呼び出すことが出来る様になった。
実際に動作を確認してみると

image.png

エラーが起こらなくなったのが分かる。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?