FreeBSDにPython3をインストールする方法

提供: Python入門
移動: 案内検索
スポンサーリンク

FreeBSDにPythonをインストールする場合は、pkg コマンドでインストールします。

読み方

Python
ぱいそん

概要

FreeBSDでpythonスクリプトを実行するときに、エラーとなり、スクリプトの先頭行を見ると python3 を要求していました。 python コマンドを調べてみると、pythonの2系しかインストールされていないことがわかりました。

$ python -V
Python 2.7.11
$ pkg info|grep ^python
python-2.7_2,2                 The "meta-port" for the default version of Python interpreter
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.11_1              Interpreted object-oriented programming language

というわけで、Python3をインストールしました。 なお、python3 をあとからインストールしたため、python2とpython3が同居しています。

パッケージの探し方

pkg search で Python3 のパッケージを検索できます。

$ pkg search python3
ap22-mod_python33-3.3.1_7      Apache module that embeds the Python interpreter within the server
ap24-mod_python35-3.5.0_2      Apache module that embeds the Python interpreter within the server
py27-wxPython30-3.0.2.0        GUI toolkit for the Python programming language
python3-3_3                    The "meta-port" for version 3 of the Python interpreter
python33-3.3.6_3               Interpreted object-oriented programming language
python34-3.4.4_1               Interpreted object-oriented programming language
python35-3.5.1_1               Interpreted object-oriented programming language

インストール

sudo pkg install python3

実行例

インストール後のpythonコマンドシリーズは、以下の通りです。

$ ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  wheel     7 103  2014 /usr/local/bin/python@ -> python2
lrwxr-xr-x  1 root  wheel    14 103  2014 /usr/local/bin/python-config@ -> python2-config
lrwxr-xr-x  1 root  wheel     9 103  2014 /usr/local/bin/python2@ -> python2.7
lrwxr-xr-x  1 root  wheel    16 103  2014 /usr/local/bin/python2-config@ -> python2.7-config
-r-xr-xr-x  1 root  wheel  5416  19 10:15 /usr/local/bin/python2.7*
-r-xr-xr-x  1 root  wheel  1769  19 10:15 /usr/local/bin/python2.7-config*
lrwxr-xr-x  1 root  wheel     9  319 10:25 /usr/local/bin/python3@ -> python3.4
lrwxr-xr-x  1 root  wheel    16  319 10:25 /usr/local/bin/python3-config@ -> python3.4-config
-r-xr-xr-x  2 root  wheel  7296  319 10:14 /usr/local/bin/python3.4*
lrwxr-xr-x  1 root  wheel    17  319 10:15 /usr/local/bin/python3.4-config@ -> python3.4m-config
-r-xr-xr-x  2 root  wheel  7296  319 10:14 /usr/local/bin/python3.4m*
-r-xr-xr-x  1 root  wheel  3048  319 10:15 /usr/local/bin/python3.4m-config*
-r-xr-xr-x  2 root  wheel  7296  19 10:15 /usr/local/bin/python3.5*
lrwxr-xr-x  1 root  wheel    17  19 10:16 /usr/local/bin/python3.5-config@ -> python3.5m-config
-r-xr-xr-x  2 root  wheel  7296  19 10:15 /usr/local/bin/python3.5m*
-r-xr-xr-x  1 root  wheel  3082  19 10:16 /usr/local/bin/python3.5m-config*

関連項目




スポンサーリンク