ベスパリブ

プログラミングを主とした日記・備忘録です。ベスパ持ってないです。

anaconda4.3.0でfcntlのflock()が使えない

・Ubuntu14.04 LTS
・pyenvを使ってAnaconda4.3.0 (python3.6.0)をインストール
で、fcntlモジュールのflock()等が使用できません。
" AttributeError: module 'fcntl'has no attribute "エラーが起きます。

$ python
Python 3.6.0 |Anaconda 4.3.0 (32-bit)| (default, Dec 23 2016, 12:22:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> fcntl.LOCK_EX
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'fcntl' has no attribute 'LOCK_EX'
>>> 

なぜ?
調べると、同じディストリビューションで困っている人を発見しました。
Python 3.6になったAnaconda 4.3.0をインストールしてはまった - Qiita

下のChangelogにあるようにいくつかパッケージが外されている。どのパッケージが該当するのかはっきりしないが、いくつか機能がなくなっている。

パッケージが外されている……いやしかし、標準ライブラリのモジュールを外すことってありえるのかな?と疑問。もしかしたらこの人とは関係ないかも?

Anaconda4.3.0のChangelogを眺めてみました。
Anaconda changelog | Continuum Analytics: Documentation

Removed (from installer only):

anaconda-clean
dynd-python
filelock <==
libdynd
nb_anacondacloud
nb_conda
nb_conda_kernels
nbpresent
patchelf
pkginfo

filelock...?うーん……。

ちなみに、システムにプリインストールされているpython2.7.6とpython3.4.3だと普通に使用できます。

$ python2
Python 2.7.6 (default, Jun 22 2015, 18:00:18) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> fcntl.LOCK_EX
2
>>> 
$ /usr/bin/python3
Python 3.4.3 (default, Oct 14 2015, 20:33:09) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> fcntl.LOCK_EX
2
>>>