PySideをanacondaで使おうとしてハマったこと
pysideでhelloworldするまでに割と時間がかかったので手順をメモ
特にImage not found に悩まされた....
最初に
brew install cmake
brew install qt
をして
pip install PySideする
意気揚々とtutoriの↓を実行するも
import sys
from PySide.QtCore import *
from PySide.QtGui import *
# Create a Qt application
app = QApplication(sys.argv)
# Create a Label and show it
label = QLabel("Hello World")
label.show()
# Enter Qt application main loop
app.exec_()
sys.exit()
Library not loaded: @rpath/libpyside.cpython-34m.1.2.dylib
Referenced from: /Users/hogehoge/anaconda/envs/py34con/lib/python3.4/site-packages/PySide/QtCore.so
Reason: image not found
となる、QtCore.soのrpathの下にdylibがないと言っているので
rpathを追加してあげる。ないって言っているファイルがあるとこを探して
install_name_toolで追加、自分の場合は下の4つで動いた
install_name_tool -add_rpath /Users/hogehoge/anaconda/envs/py34con/lib/python3.4/site-packages/PySide QtGui.so
install_name_tool -add_rpath /Users/hogehoge/anaconda/envs/py34con/lib/python3.4/site-packages/PySide QtCore.so
install_name_tool -add_rpath /Users/hogehoge/anaconda/lib QtGui.so
install_name_tool -add_rpath /Users/hogehoge/anaconda/lib QtCore.so