簡體   English   中英

如何解決 python 人性化錯誤:ImportError cannot import name on_windows from 'humanfriendly.compat'

[英]How to resolve python humanfriendly error: ImportError cannot import name on_windows from 'humanfriendly.compat'

我在 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

~\Anaconda3\lib\site-packages\humanfriendly\__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

~\Anaconda3\lib\site-packages\humanfriendly\tables.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,

~\Anaconda3\lib\site-packages\humanfriendly\terminal\__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:\Users\Me\Anaconda3\lib\site-packages\humanfriendly\compat.py)

我在 google 或 StackOverflow 上找不到與此錯誤消息特別相關的任何內容。

如何解決此錯誤?

最終將問題追溯到人性化的 Anaconda 版本,其中不包括“on_windows”function。 conda-forge 版本可以。

我用了

conda remove humanfriendly

然后

conda install --channel "conda-forge" humanfriendly

問題解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM