pyenv上でimport cursesするとNo module namedとなるので対処したメモ

2017-09-12 10:18:04

pyenv virtualenv 3.5.2 xxxxxした環境で、import cursesしたらおこられた

$ python
Traceback (most recent call last):
  File "", line 4, in <module>
    import curses
  File "/home/username/.anyenv/envs/pyenv/versions/3.5.2/lib/python3.5/curses/", line 13, in <module>
    from _curses import *
ImportError: No module named '_curses'


The C modules of Python is not a script file and it must not work even if you just copy it. You must rebuild the Python and modules against system's curses library. The lack of library or development headers of curses (e.g. libncursesw5-dev) might causes those issues. Please confirm if you have enough package for the module.



// cursesのライブラリ類インストール
$ sudo apt-get install libncurses5 libncurses5-dev libncursesw5

// install済みの物を1回削除して再構築
$ pyenv uninstall 3.5.2
$ pyenv install 3.5.2
$ pyenv virtualenv 3.5.2 xxxxx