如何解决python人性化错误:ImportError无法从'humanfriendly.compat'导入名称on_windows



我在windows 10上,使用python 3.7.3

如果我打开一个ipython终端并键入:

import humanfriendly

我得到以下错误:

In [7]: import humanfriendly
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-69d5bc3698c4> in <module>
----> 1 import humanfriendly
~Anaconda3libsite-packageshumanfriendly__init__.py in <module>
23 # support for other tables has been added and the name of format_table() has
24 # changed. The following import statement preserves backwards compatibility.
---> 25 from humanfriendly.tables import format_pretty_table as format_table
26
27 # In humanfriendly 1.30 the following text manipulation functions were moved
~Anaconda3libsite-packageshumanfriendlytables.py in <module>
30 # Modules included in our package.
31 from humanfriendly.compat import coerce_string
---> 32 from humanfriendly.terminal import (
33     ansi_strip,
34     ansi_width,
~Anaconda3libsite-packageshumanfriendlyterminal__init__.py in <module>
43
44 # Modules included in our package.
---> 45 from humanfriendly.compat import coerce_string, is_unicode, on_windows, which
46 from humanfriendly.decorators import cached
47 from humanfriendly.deprecation import define_aliases
ImportError: cannot import name 'on_windows' from 'humanfriendly.compat' (C:UsersMeAnaconda3libsite-packageshumanfriendlycompat.py)

我在谷歌或StackOverflow上找不到任何与此错误消息相关的内容。

如何解决此错误?

最终将问题追溯到Anaconda版本的人性化,该版本不包括'on_windows'功能。conda-forge版本确实如此。

我使用

conda remove humanfriendly

然后

conda install --channel "conda-forge" humanfriendly

问题解决了。

相关内容

最新更新