0

I have 3 jupyter notebooks. The 2nd one import the first one. The 3rd one import the 2nd one. I installed ipynb and used the below codes the import previous notebook.

Running 2nd notebook is fine with imported data and plot from 1st notebook. However when I run the 3rd notebook, the error says:

ImportError: Could not import 2ndnotebook.ipynb for ipynb.fs.full.RCA_2ndnotebook: not a valid ipynb file

what is the reason? Thanks for your help.

from ipynb.fs.full.firstnotebook import *

The detail errors are:

UnicodeDecodeError                        Traceback (most recent call last)
~\miniconda3\envs\tf_cpu\lib\site-packages\ipynb\fs\full\__init__.py in get_code(self, fullname)
     28                 try:
---> 29                     nb = json.load(f)
     30                 except ValueError:

~\miniconda3\envs\tf_cpu\lib\json\__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    292     """
--> 293     return loads(fp.read(),
    294         cls=cls, object_hook=object_hook,

~\miniconda3\envs\tf_cpu\lib\encodings\cp1252.py in decode(self, input, final)
     22     def decode(self, input, final=False):
---> 23         return codecs.charmap_decode(input,self.errors,decoding_table)[0]
     24 

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 11976754: character maps to <undefined>

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-5-678a15847c0e> in <module>
----> 1 from ipynb.fs.full.2ndnotebook import *

~\miniconda3\envs\tf_cpu\lib\site-packages\ipynb\fs\full\__init__.py in get_code(self, fullname)
     30                 except ValueError:
     31                     # This is when it isn't a valid json file
---> 32                     raise ImportError('Could not import {path} for {fn}: not a valid ipynb file'.format(
     33                         path=self.path,
     34                         fn=fullname

ImportError: Could not import 2ndnotebook.ipynb for ipynb.fs.full.2ndnotebook: not a valid ipynb file

roudan
  • 3,082
  • 5
  • 31
  • 72
  • anyone here can help me? Thanks – roudan Jul 16 '21 at 19:27
  • 1
    Nothing worked until I read this :) https://stackoverflow.com/questions/20186344/importing-an-ipynb-file-from-another-ipynb-file -------------------------------- "%run MyOtherNotebook.ipynb" I tried a lot of other things and got a lot of errors, and thought I had a solution, but in "reality" it failed. – rrogers Jan 02 '22 at 17:15

0 Answers0