"UnsupportedOperation: fileno" in Spacy Jupyter Notebook
Asked Answered
P

3

7

Anyone might know what this error is about and what to do about it?

Spacy works in python command line interface though.

I have tried to google various parts of the error, but found nothing specific.

This has been on Conda, on Windows 11, with Python 3.9.

Error message below for reference.

UnsupportedOperation                      Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4264/572880994.py in <module>
----> 1 import spacy

C:\ProgramData\Anaconda3\lib\site-packages\spacy\__init__.py in <module>
      4 
      5 # set library-specific custom warning handling before doing anything else
----> 6 from .errors import setup_default_warnings
      7 
      8 setup_default_warnings()  # noqa: E402

C:\ProgramData\Anaconda3\lib\site-packages\spacy\errors.py in <module>
      1 import warnings
----> 2 from .compat import Literal
      3 
      4 
      5 class ErrorsWithCodes(type):

C:\ProgramData\Anaconda3\lib\site-packages\spacy\compat.py in <module>
      1 """Helpers for Python and platform compatibility."""
      2 import sys
----> 3 from thinc.util import copy_array
      4 
      5 try:

C:\ProgramData\Anaconda3\lib\site-packages\thinc\__init__.py in <module>
      3 
      4 from .about import __version__
----> 5 from .config import registry

C:\ProgramData\Anaconda3\lib\site-packages\thinc\config.py in <module>
     11 from pydantic.main import ModelMetaclass
     12 from pydantic.fields import ModelField
---> 13 from wasabi import table
     14 import srsly
     15 import catalogue

C:\ProgramData\Anaconda3\lib\site-packages\wasabi\__init__.py in <module>
     10 from .about import __version__  # noqa
     11 
---> 12 msg = Printer()

C:\ProgramData\Anaconda3\lib\site-packages\wasabi\printer.py in __init__(self, pretty, no_print, colors, icons, line_max, animation, animation_ascii, hide_animation, ignore_warnings, env_prefix, timestamp)
     54         self.pretty = pretty and not env_no_pretty
     55         self.no_print = no_print
---> 56         self.show_color = supports_ansi() and not env_log_friendly
     57         self.hide_animation = hide_animation or env_log_friendly
     58         self.ignore_warnings = ignore_warnings

C:\ProgramData\Anaconda3\lib\site-packages\wasabi\util.py in supports_ansi()
    262         if "ANSICON" in os.environ:
    263             return True
--> 264         return _windows_console_supports_ansi()
    265 
    266     return True

C:\ProgramData\Anaconda3\lib\site-packages\wasabi\util.py in _windows_console_supports_ansi()
    234             raise ctypes.WinError()
    235 
--> 236     console = msvcrt.get_osfhandle(sys.stdout.fileno())
    237     try:
    238         # Try to enable ANSI output support

C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\iostream.py in fileno(self)
    306             return self._original_stdstream_copy
    307         else:
--> 308             raise io.UnsupportedOperation("fileno")
    309 
    310     def _watch_pipe_fd(self):

UnsupportedOperation: fileno
Palacios answered 29/7, 2022 at 3:36 Comment(1)
It looks like I was just unlucky: github.com/explosion/spaCy/issues/11236Palacios
P
12

The issue was temporarily addressed by uninstall the current version of Wasabi with an older one.

pip uninstall wasabi -y

pip install wasabi==0.9.1

The folks from Github mentioned that a newer version of Wasabi should avoid this problem.

Palacios answered 29/7, 2022 at 6:11 Comment(6)
I had the same problem on Windows 10 in a conda-forge environment, and user3081750's answer worked for me.Germanize
@Germanize How did u do that for conda?Icao
conda install wasabi==0.9.1 -c conda-forge, and then I pinned wasabi to 0.9.1 in the conda-meta folder for that environment. With wasabi > 0.9.1, spacy will not import at all at this time, leading to much confusion and frustration.Germanize
@GeorgeRaveen Open Anaconda Prompt and write these two commands as it is in the prompt. It will work. It worked for me.Ravelin
@Palacios What is "the current version" of wasabi mentioned in the answer?Cathrine
Had the same issue. The above solution worked for me.Andrade
T
3

I have the same issue. Maybe you can try that.

conda update spacy

It solved my problem.

Trichoid answered 6/8, 2022 at 11:59 Comment(1)
Thanks!! Me too, dont forget kernel restartOmega
G
0

This issue has been fixed with spaCy 3.4.3 and wasabi 0.10.1, at least using Python 3.9.

Germanize answered 12/11, 2022 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.