0

I'm using jupyter notebook in firefox and I keep getting this error whenever I run a program [E 19:06:49.747 NotebookApp] Error while saving file: xG_SetPiece_Model.ipynb [Errno 9] Bad file descriptor

The full error in powershell is:

[E 19:06:49.747 NotebookApp] Error while saving file: xG_SetPiece_Model.ipynb [Errno 9] Bad file descriptor
    Traceback (most recent call last):
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\filemanager.py", line 493, in save
        self._save_notebook(os_path, nb)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 290, in _save_notebook
        nbformat.write(nb, f, version=nbformat.NO_CONVERT)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 126, in __exit__
        next(self.gen)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 210, in atomic_writing
        yield f
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 126, in __exit__
        next(self.gen)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 118, in atomic_writing
        os.fsync(fileobj.fileno())
    OSError: [Errno 9] Bad file descriptor
[W 19:06:49.747 NotebookApp] 500 PUT /api/contents/xG_SetPiece_Model.ipynb (127.0.0.1): Unexpected error while saving file: xG_SetPiece_Model.ipynb [Errno 9] Bad file descriptor
[W 19:06:49.747 NotebookApp] Unexpected error while saving file: xG_SetPiece_Model.ipynb [Errno 9] Bad file descriptor
[E 19:06:49.747 NotebookApp] {
      "Host": "localhost:8888",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Referer": "http://localhost:8888/notebooks/xG_SetPiece_Model.ipynb",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0"
    }
[E 19:06:49.762 NotebookApp] 500 PUT /api/contents/xG_SetPiece_Model.ipynb (127.0.0.1) 1319.730000ms referer=http://localhost:8888/notebooks/xG_SetPiece_Model.ipynb
[I 19:07:33.833 NotebookApp] Saving file at /xG_SetPiece_Model.ipynb
[I 19:09:48.442 NotebookApp] Saving file at /xG_SetPiece_Model.ipynb
[E 19:09:51.971 NotebookApp] Error while saving file: xG_SetPiece_Model.ipynb [Errno 9] Bad file descriptor
    Traceback (most recent call last):
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\filemanager.py", line 493, in save
        self._save_notebook(os_path, nb)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 290, in _save_notebook
        nbformat.write(nb, f, version=nbformat.NO_CONVERT)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 126, in __exit__
        next(self.gen)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 210, in atomic_writing
        yield f
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 126, in __exit__
        next(self.gen)
      File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\notebook\services\contents\fileio.py", line 118, in atomic_writing
        os.fsync(fileobj.fileno())
    OSError: [Errno 9] Bad file descriptor

System

  • Windows 10
  • Python 3.9.12 (64 bit)
  • Pip 22.3
  • Jupyter 1.0.0

The snapshot of jupyter notebook interface Jupyter notebook error using fireox browser

I've tried some solutions but they haven't wokrked.

  1. Reinstalling jupyter notebook suggested on github
  2. Fixing the permission issues suggested on stackoverflow
DataNoob
  • 77
  • 3
  • 10
  • 1
    What do you mean by 'keep getting' exactly? Did it just start happening today when things worked yesterday or a few days ago? Do notebooks sometimes save fine? What do you mean by 'whenever I run a program'? Meaning when you run Jupyter notebook? So it doesn't launch or does launch in your case? One of the ones you referenced [here](https://github.com/jupyter/notebook/issues/5919#issuecomment-753515775), the case was where Jupyter notebook didn't launch. – Wayne Nov 03 '22 at 16:52
  • @Wayne The jupyter notebook opens fine. Then I run some cells. And after some time of running this error pops and it doesn't go away. The cells get executed but the jupyter notebooks' autosave fails and sometimes the .ipynb file crashes. It is annoying. – DataNoob Nov 03 '22 at 17:39
  • 1
    Only this notebook triggers it or notebook that just has `2 +2` in 5 cells has the same issue? – Wayne Nov 03 '22 at 18:00
  • All notebooks are having the same issue. @Wayne – DataNoob Nov 03 '22 at 18:19
  • 1
    Had it been working correctly? Or is this a fairly new installation? – Wayne Nov 03 '22 at 18:40
  • 6 months ago I replaced my HDD. And also installed a new SSD. So python is actually installed on SSD (C drive) and the jupyter notebooks are on HDD (E drive). I reinstalled everything correctly i think. This error started arising a week or 2 ago. @Wayne – DataNoob Nov 03 '22 at 18:51
  • 1
    If you didn't change anything else before that, could it be a legitimate warning caused by bad sectors? Based on your drive paths, it looks like you aren't using [the Anaconda distribution](https://www.anaconda.com/products/distribution). If you have space on your drive and don't wish to hack around otherwise, I'd suggest install that to a single drive and see if running the Anaconda navigator and launching Jupyter from there let's you run Jupyter and save files. – Wayne Nov 04 '22 at 12:39

0 Answers0