在Windows上,用Python导入pick模块会出现以下错误:

ModuleNotFoundError: No module named ‘_curses’

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
>>> from pick import pick
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "I:\PYTHON~1\lib\site-packages\pick\__init__.py", line 3, in <module>
    import curses
  File "I:\PYTHON~1\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
>>> from pick import pick
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "I:\PYTHON~1\lib\site-packages\pick\__init__.py", line 3, in <module>
    import curses
  File "I:\PYTHON~1\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'

原因就是 curses 这个模块不支持Windows:

1
2
3
4
D:\Users\tracis>pip install curses
Collecting curses
  Could not find a version that satisfies the requirement curses (from versions: )
No matching distribution found for curses

在pick的安装描述中有一个提醒,说到了这个问题,但是自己开始的时候没注意到。

Note for Windows: curses wheels can be obtained from http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses, then install it with pip, for example: pip install curses-2.2-cp27-none-win_amd64.whl

https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses 网站下载第三方的wheels 安装包,用 pip 安装即可。

blob.jpg