python - 如何解决 python 人性化错误: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 上找不到与此错误消息特别相关的任何内容。
如何解决此错误?
解决方案
最终将问题追溯到不包含“on_windows”功能的 Anaconda 版本的humanfriendly。conda-forge 版本可以。
我用了
conda remove humanfriendly
然后
conda install --channel "conda-forge" humanfriendly
问题解决了。
推荐阅读
- android - 在循环中动态创建视图(textView、imageVIew 等)会挂起 Android 设备。如何解决这个问题?
- javascript - 光滑的灯箱使用图像标题作为标题
- sql - 选择每个联系人的最早日期
- lean - 如何在 Emacs 中为 Lean 2 切换到 HoTT 模式
- nhibernate - 是否可以根据 NHibernate 多列用户类型订购查询,最好是通过 QueryOver?
- python - 如何提高嵌套 try-except-else 子句中的代码清晰度?
- node.js - API 在将数据放入 dynamoDB 时随机工作
- java - 如何根据来自 ajax 的弹出窗口或对话框的输入来执行控制器
- php - 如何在学说中生成此查询?
- typescript - 打字稿两个接口类型应该相同