QNAP環境構築手順 Pythonモジュールのインストール

Python2のeasy_installは、setuptools を導入しました。
どうもPython3ではdistributeを使用するようです。
あと、easy_installの新しい?pipもインストールします。



distributeをipkgで楽々インストール!!っと思ったら、
失敗しました。。。。。
うーむ、こんなんばっかり。


とりあえず、SSHで手動でインストールです。

(1)distributeをダウンロード&解答

[/tmp/usertmp/20120318] # wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.25.tar.gz#md5=a690874b9964d958a3200485eb827b1d

Resolving pypi.python.org... 82.94.164.168, 2001:888:2000:d::a8
Connecting to pypi.python.org|82.94.164.168|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 629502 (615K) [application/octet-stream]
Saving to: `distribute-0.6.25.tar.gz'

100%[====================================================================================================================================>] 629,502 235K/s in 2.6s

2012-03-18 20:18:55 (235 KB/s) - `distribute-0.6.25.tar.gz' saved [629502/629502]

[/tmp/usertmp/20120318] #
[/tmp/usertmp/20120318] #
[/tmp/usertmp/20120318] # tar zxvf distribute-0.6.25.tar.gz
distribute-0.6.25/
distribute-0.6.25/.hg/
distribute-0.6.25/.hg/last-message.txt
distribute-0.6.25/.hgignore
省略

(2)distributeのインストール

[/tmp/usertmp/20120318] # ls -la
drwxr-xr-x 3 admin administ 80 Mar 18 20:20 ./
drwxr-xr-x 3 admin administ 60 Mar 18 20:18 ../
drwxrwxrwx 8 admin administ 520 Mar 10 16:07 distribute-0.6.25/

  • rw-r--r-- 1 admin administ 629502 Mar 10 16:08 distribute-0.6.25.tar.gz

[/tmp/usertmp/20120318] # cd distribute-0.6.25
[/tmp/usertmp/20120318/distribute-0.6.25] #

[/tmp/usertmp/20120318/distribute-0.6.25] # python3 ./setup.py install
creating build
creating build/src
creating build/src/docs
省略

成功


(3)インストール先の確認

◆サイトパッケージ

[/opt/local/lib/python3.2/site-packages] # pwd
/opt/local/lib/python3.2/site-packages
[/opt/local/lib/python3.2/site-packages] # ls -la
drwxr-xr-x 3 admin administ 4096 Mar 18 20:25 ./
drwxr-xr-x 3 admin administ 4096 Mar 17 13:28 ../
drwxr-xr-x 4 admin administ 4096 Mar 18 20:25 distribute-0.6.25-py3.2.egg/

  • rw-r--r-- 1 admin administ 215 Mar 18 20:25 easy-install.pth
  • rw-r--r-- 1 admin administ 144 Mar 18 20:25 setuptools-0.6c11-py3.2.egg-info
  • rw-r--r-- 1 admin administ 34 Mar 18 20:25 setuptools.pth

[/opt/local/lib/python3.2/site-packages] #


◆実行バイナリー

[/opt/local/lib/python3.2/site-packages] # ls /opt/local/bin
easy_install* easy_install-3.2*
[/opt/local/lib/python3.2/site-packages] #

(4)pipのインストール

こいつはeasy_install で楽々インストールです。

[/opt/local/bin] # python ./easy_install pip
/opt/local/lib/python2.5/site-packages (in --site-dirs) does not exist
Searching for pip
Reading http://pypi.python.org/simple/pip/
Reading http://pip.openplans.org
Reading http://www.pip-installer.org
Best match: pip 1.1
Downloading http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz#md5=62a9f08dd5dc69d76734568a6c040508
Processing pip-1.1.tar.gz
Running pip-1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-16p8dp/pip-1.1/egg-dist-tmp-712hxn
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Adding pip 1.1 to easy-install.pth file
Installing pip script to /opt/local/bin
Installing pip-3.2 script to /opt/local/bin

Installed /share/******A/.qpkg/Optware/local/lib/python3.2/site-packages/pip-1.1-py3.2.egg
Processing dependencies for pip
Finished processing dependencies for pip
[/opt/local/bin] #

MySql接続用モジュールのインストール

最初python2で使用していたMySQL for Python(MySQLdb)をインストールしようとしていましたが、
まだPython3に対応していない?ようなのでpymysqlってのをインストールして対応しました。

こいつはpipで楽々インストール!!と思ったら失敗しました。。。。
手動インストールです。

ファイルダウンロード&解凍

[/tmp/usertmp/20120318] # wget http://pypi.python.org/packages/source/P/PyMySQL3/PyMySQL3-0.5.tar.gz#md5=9157b6068f9b2a277d8b126ef05bab3a

Resolving pypi.python.org... 82.94.164.168, 2001:888:2000:d::a8
Connecting to pypi.python.org|82.94.164.168|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30593 (30K) [application/octet-stream]
Saving to: `PyMySQL3-0.5.tar.gz'

100%[===================================================================================================================================================================================================>] 30,593 34.3K/s in 0.9s

2012-03-19 00:31:43 (34.3 KB/s) - `PyMySQL3-0.5.tar.gz' saved [30593/30593]

[/tmp/usertmp/20120318] #

[/tmp/usertmp/20120318] # tar zxvf ./PyMySQL3-0.5.tar.gz
PyMySQL3-0.5/
PyMySQL3-0.5/PKG-INFO
PyMySQL3-0.5/pymysql/
省略
PyMySQL3-0.5/pymysql/tests/test_DictCursor.py
PyMySQL3-0.5/pymysql/tests/test_example.py
PyMySQL3-0.5/pymysql/tests/test_issues.py
PyMySQL3-0.5/pymysql/times.py
PyMySQL3-0.5/pymysql/util.py
PyMySQL3-0.5/setup.py
[/tmp/usertmp/20120318] #

インストール

[/tmp/usertmp/20120318] #cd PyMySQL3-0.5
[/tmp/usertmp/20120318/PyMySQL3-0.5] # python3 ./setup.py install
running install
/opt/local/lib/python2.5/site-packages (in --site-dirs) does not exist
Checking .pth file support in /opt/local/lib/python3.2/site-packages/
/opt/bin/python3 -E -c pass
TEST PASSED: /opt/local/lib/python3.2/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
creating PyMySQL3.egg-info
writing PyMySQL3.egg-info/PKG-INFO
省略
byte-compiling build/bdist.linux-armv5tel/egg/pymysql/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-armv5tel/egg/pymysql/err.py to err.pyc
byte-compiling build/bdist.linux-armv5tel/egg/pymysql/times.py to times.pyc
byte-compiling build/bdist.linux-armv5tel/egg/pymysql/util.py to util.pyc
creating build/bdist.linux-armv5tel/egg/EGG-INFO
copying PyMySQL3.egg-info/PKG-INFO -> build/bdist.linux-armv5tel/egg/EGG-INFO
copying PyMySQL3.egg-info/SOURCES.txt -> build/bdist.linux-armv5tel/egg/EGG-INFO
copying PyMySQL3.egg-info/dependency_links.txt -> build/bdist.linux-armv5tel/egg/EGG-INFO
copying PyMySQL3.egg-info/top_level.txt -> build/bdist.linux-armv5tel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/PyMySQL3-0.5-py3.2.egg' and adding 'build/bdist.linux-armv5tel/egg' to it
removing 'build/bdist.linux-armv5tel/egg' (and everything under it)
Processing PyMySQL3-0.5-py3.2.egg
creating /share/********/.qpkg/Optware/local/lib/python3.2/site-packages/PyMySQL3-0.5-py3.2.egg
Extracting PyMySQL3-0.5-py3.2.egg to /share/*********/.qpkg/Optware/local/lib/python3.2/site-packages
Adding PyMySQL3 0.5 to easy-install.pth file

Installed /share/*********/.qpkg/Optware/local/lib/python3.2/site-packages/PyMySQL3-0.5-py3.2.egg
Processing dependencies for PyMySQL3==0.5
Finished processing dependencies for PyMySQL3==0.5
[/tmp/usertmp/20120318/PyMySQL3-0.5] #


とりあえず、pythoモジュールインストール完了です。
実際にはMySqlに接続には、いろいろ設定がいりますが、別で記載しあます。