トップ 差分 一覧 ソース 検索 ヘルプ PDF RSS ログイン

FreeBSD python

  • FreeBSD-11 ports での python のバージョン管理について
  • FreeBSD-11 では /etc/make.conf に DEFAULT_VERSIONS+=python=2.7 や DEFAULT_VERSIONS+=python=3.6 を定義することで ports/python-sqlite3 の ports をインストールできる。
  • python27-sqlite3
  • python35-sqlite3
  • python36-sqlite3

MULTIPLE PYTHON VERSIONS IN FREEBSD / izabeera and dryobates

It’s easy to install multiple versions of Python with FreeBSD ports.

I had a problem with sqlite3:

ImportError: No module named _sqlite3

With default Python version I can install it from "databases/py-sqlite3" doing "make install" like above. How to install it for Python3.x? There's no py34-sqlite3 port.

The key is to set PYTHON_VERSION environment variable:

$ cd /usr/ports/databases/py-sqlite3
$ make PYTHON_VERSION=3.2 install clean
$ make PYTHON_VERSION=3.3 install clean
$ make PYTHON_VERSION=3.4 install clean
  • 上記は 2014年の記事

2019年 FreeBSD-11

# make PYTHON_VERSION=3.5 install
===>  Installing for py36-sqlite3-3.6.8_7
===>  Checking if py36-sqlite3 is already installed
===>   py36-sqlite3-3.6.8_7 is already installed

...

*** Error code 1

Stop.
make: stopped in /usr/ports/databases/py-sqlite3
  • /usr/ports/Mk/bsd.default-versions.mk
root@ns4:/usr/ports/databases/py-sqlite3 # grep PYTHON /usr/ports/Mk/bsd.default-versions.mk | grep DEFAULT
PYTHON_DEFAULT?=        3.6
PYTHON2_DEFAULT?=       2.7
PYTHON3_DEFAULT?=       3.6
  • 失敗#1
root@ns4:/usr/ports/databases/py-sqlite3 # make PYTHON_DEFAULT=2.7
/!\ ERRORS /!\

The variable PYTHON_DEFAULT is set and it should only be defined through
DEFAULT_VERSIONS+=python=2.7 in /etc/make.conf
  • /etc/make.conf 追加
DEFAULT_VERSIONS+=python=2.7
root@ns4:/usr/ports/databases/py-sqlite3 # make
===>  License PSFL accepted by the user
===>   py27-sqlite3-2.7.16_7 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by py27-sqlite3-2.7.16_7 for building
  • /etc/make.conf 修正
DEFAULT_VERSIONS+=python=3.6
root@ns4:/usr/ports/databases/py-sqlite3 # make
===>  License PSFL accepted by the user
===>   py36-sqlite3-3.6.8_7 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by py36-sqlite3-3.6.8_7 for building
  • FreeBSD-11 では /etc/make.conf に DEFAULT_VERSIONS+=python=2.7 や DEFAULT_VERSIONS+=python=3.6 を定義することで python-sqlite3 の ports をインストールできる。