我在Windows 7(x64)计算机上安装了Python 2.7 / 3.4。我想在Windows上测试curses。
已安装Curses但无法正常工作:
>>> import curses
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Tools\Python3.4.2\lib\curses\__init__.py", line 13, in <module>
from _curses import *
ImportError: No module named '_curses'
因此,Python 3.4的Windows安装程序安装了具有未解析依赖项的curses。有人可以说这是一个错误......
好的,我调查了UniCurses。它是PDCurses的包装器:
UniCurses是Python 2.x / 3.x的包装器,它在所有平台(MS Windows,Linux和Mac OS X)上提供统一的Curses功能集,其语法接近原始NCurses的语法。要在Microsoft Windows系统上提供Curses功能,它将包装PDCurses。
通过pip3
安装UniCurses会导致错误:
C:\Users\Paebbels>pip3 install UniCurses
Downloading/unpacking UniCurses
Could not find any downloads that satisfy the requirement UniCurses
Some externally hosted files were ignored (use --allow-external UniCurses to allow).
Cleaning up...
No distributions at all found for UniCurses
Storing debug log for failure in C:\Users\Paebbels\pip\pip.log
在Python的UniCurses网站上链接到SourceForge已经死了。手动搜索SourceForge有助于再次找到UniCurses for Python。
但是,UniCurses 1.2安装程序在我的Windows注册表中找不到任何Python安装。 (Python 2.7.9和Python 3.4.2可用)。
我也研究过Public Domain Curses(PDCurses)。 PD Cureses 3.4来自2008年底。所以它已经7岁了。我不相信它适用于Windows 7,Windows 8.1或Windows 10。
有没有办法让使用Python在Windows上运行curses。
(Windows Python,而不是CygWin Python!)
答案 0 :(得分:57)
如果您手动安装Windows或其他软件包,则可以使用curses跨平台(Windows,MacOS,GNU / Linux)。
安装滚轮包。如果您需要有关wheel click here。
下载包含python版本的软件包,例如python 3.4:
body {
padding: 20px;
}
.container {
border: 1px solid lime;
padding: 10px;
width: 200px;
}
.test1 {
display: none;
border: 1px dashed orange;
background: green;
padding: 10px;
pointer-events: none;
}
.container:hover .test1 {
display: inline-block;
}
a {
pointer-events: auto;
color: lime;
font-weight: bold;
}
.container .test1 {
-webkit-animation: seconds 1.0s forwards;
-webkit-animation-iteration-count: 1;
-webkit-animation-delay: 2s;
animation: seconds 1.0s forwards;
animation-iteration-count: 1;
animation-delay: 2s;
position: relative;
}
@-webkit-keyframes seconds {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
@keyframes seconds {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
安装它(如果对于Windows,这个命令,在GNU / Linux安装中像其他包一样)
<ul class="container">
Drop down menu
<li class="test1">
<a class="dropdown" href="#">X Close</a>
<ul class="content">
CLOSE THIS CONTENT
<li class="link"><a href="http://www.google.com">Go to link 1</a></li>
<li class="link"><a href="https://www.google.co.uk">Go to link 2</a></li>
<li class="link"><a href="https://www.google.co.uk">Go to link 3</a></li>
</ul>
只需包含在您的python脚本中:
curses-2.2-cp34-none-win_amd64.whl
你可以使用curses包装器来实现python。适用于所有终端的Fedora 25,以及使用git bash,powershell或cmd的Windows 10。
更新
答案 1 :(得分:8)
您可以尝试my mirror of unicurses,其中包括pdcurses dll。我现在已经使用python 3.5.0在Windows 7上运行了。
要快速测试它是否适合您,只需克隆存储库并在其顶层目录中创建并运行python脚本,其中包含类似
的内容use strict;
use warnings;
die "Usage: $0 <text> <characters>" if @ARGV < 1;
my $search = shift; # the string you are looking for
my $str; # the input string
if (@ARGV && -e $ARGV[0] || !@ARGV) { # if str is file, or there is no str
local $/; # slurp input
$str = <>; # use diamond operator
} else { # else just use the string
$str = shift;
}
my $count = () = $str =~ /\Q$search\E/gms;
print "Found $count of '$search' in '$str'\n";
答案 2 :(得分:1)
现在我们可以使用scope :prospects, -> () { where prospect: true }