简体   繁体   中英

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

I'm on windows 10 and using python 3.7.3

If I open an ipython terminal and type:

import humanfriendly

I get the following error:

        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)

I cannot find anything specifically related to this error msg on google or StackOverflow.

How do I resolve this error?

Eventually traced the issue to the Anaconda version of humanfriendly which does not include the 'on_windows' function. The conda-forge version does.

I used

conda remove humanfriendly

then

conda install --channel "conda-forge" humanfriendly

Problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM