2009年3月30日 星期一
2009年3月19日 星期四
在Python中使用relative path的好處
#!/usr/bin/env python
於是會以 /usr/bin/env 程式來叫用 python 直譯器,處理 Python 程式檔案。這麼作的好處是當系統中安裝有許多個不同的 Python 直譯器時,會採用路徑在最前面的那一個。如此一來,若使用者另外安裝了一版 Python (例如裝在自己的家目錄),又把自己的 Python 放到路徑設定 (PATH 環境變數) 的最前面,即會採用使用者自己安裝的 Python。
2009年3月12日 星期四
Updating the locate database in Mac OS X
`/var/db/locate.database': No such file or directory
執行database的建立, 就可以解決這個問題:sudo /usr/libexec/locate.updatedb
2009年3月11日 星期三
安裝PyQt和Qt在Leopard的方法
Building Qt 4 and PyQt on Mac OS X Leopard
Things we need for a successful build:
- Qt Open Source Edition 4 source tarball from Trolltech
- SIP source tarball from Riverbank
- PyQt source tarball from Riverbank
Just let the built-in Archive Utility to extract the tarballs somewhere on your disk.
1. Building Qt
This is pretty straightforward, just follow the instructions:
cd qt-mac-opensource-src-4.5.0/
./configure
make
sudo make install
2. Building SIP
This needs some tweaking, since SIP’s and PyQt’s setup scripts put the module files into a folder that’s not recognized by Python on the new Leopard OS.
cd sip-4.7.1/
python configure.py -d /Library/Python/2.5/site-packages
make
sudo make install
3. Building PyQt
The same applies here.
cd PyQt-mac-gpl-4.3.1/
python configure.py -q /usr/local/Trolltech/Qt-4.3.2/bin/qmake -d /Library/Python/2.5/site-packages
make
sudo make install
Making the steps above, I was able to run any sample PyQt script. The issue I saw that the menubar constantly says “Python”. I hope one can change this to the application’s title (C++ Qt apps look fine).