在Cygwin终端中运行时,是否可以让我的Windows Python安装知道它可以使用的额外库?

2024-10-16 20:46:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用下面的Python包,它需要ncurses:https://pypi.python.org/pypi/blessings

我已经安装了Anaconda Python的Windows版本,并将其指定为Python发行版。 我还有一个Cygwin装置。当我在所提供的CygWin终端中运行^ {< CD2> }时,PythonPython启动了——太棒了!在

如果我再尝试import blessings,将得到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "A:\anaconda\lib\site-packages\blessings\__init__.py", line 5, in <module>
    import curses
  File "A:\anaconda\lib\curses\__init__.py", line 15, in <module>
    from _curses import *
ImportError: No module named _curses

好吧,那么现在发生的是,Python不接Cygwin的诅咒是可以理解的。在

现在,仅仅在Cygwin终端中使用的上下文中,尝试并以某种方式使Anaconda知道ncurses有意义吗?我怀疑不是,而且我在概念上遗漏了什么?在


Tags: inimportpypi终端initliblineanaconda
1条回答
网友
1楼 · 发布于 2024-10-16 20:46:29

不幸的是,您不能将cygwinpython的curses模块与CPython一起使用。两个Python的模块不兼容,原因如下:

Windows Python直接调用win32api(通过visualstudio2008、2010或2015 C-Runtimes),而Cygwin Python链接到Cygwin POSIX API,该API位于visualstudio6.0c-Runtime之上。在单个进程中混合不同的C运行时是一个非常糟糕的主意:http://siomsystems.com/mixing-visual-studio-versions/,更不用说通过posixapi进一步抽象了。在

不管C运行时的不同,Cygwin实现的是LP64模型,而Windows实现的是LLP64模型,这将使long的64位大小不同,因此某些结构的大小可能不同。它们很可能是由于代码中的ifdef。在

有什么原因不能使用colorama? 福佑的文档表明这应该有效。在

相关问题 更多 >