You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to import ipynb as it gives the error: "ipynb\fs\full_init_.py", line 39, in get_code raise ImportError('Could not import {path} for {fn}: incorrect version or language"
Is this ipynb import supported only for some python versions?
I too experienced this error. I found that the validate_nb() method in "utils.py" is searching the within notebook's kernelspec dictionary for the dictionary key language. My particular notebook did not have this key. It only has name and display_name, which would need to be further parsed to determine that language_name == 'python'
It would seem that this issue is still present on Google Colab. PR #51 doesn't seem to have been merged. The latest commit on main branch in this repo was on Oct 2017. To anyone reading this, I think this repo may not be active at the moment.
ImportError Traceback (most recent call last)
<ipython-input-6-1be176fa1f93> in <module>()
----> 1 import ipynb.fs.full.asdf
/usr/local/lib/python3.7/dist-packages/ipynb/fs/full/__init__.py in get_code(self, fullname)
39 raise ImportError('Could not import {path} for {fn}: incorrect version or language'.format(
40 path=self.path,
---> 41 fn=fullname
42 ))
43 return self.source_to_code(code_from_ipynb(nb), self.path)
ImportError: Could not import /content/drive/MyDrive/Colab Notebooks/asdf.ipynb for ipynb.fs.full.asdf: incorrect version or language
Following on @abergerSRS answer, I looked at what the utils/validate_nb(nb) function was doing and a quick (and certainly dirty) fix is open the ipynb metadata (open it using notes, for example) adding language to a dict like below.
I do not know why this check is being made, and I am unaware of possible side effects. Therefore, I do not responsibilize myself if something goes wrong.
Activity
AnupamSaraph commentedon Mar 15, 2021
Unable to import ipynb as it gives the error: "ipynb\fs\full_init_.py", line 39, in get_code raise ImportError('Could not import {path} for {fn}: incorrect version or language"
Is this ipynb import supported only for some python versions?
rajkundu commentedon Mar 26, 2021
Same issue here using Python 3.8.5 on macOS 10.15.7. Perhaps it has to do with me using "/usr/local/bin/python3"? I'm working in VS Code.
o-inha commentedon Mar 26, 2021
Btw, my workaround was to use import-ipynb instead.
rajkundu commentedon Mar 26, 2021
Ah, thank you - I ended up finding importnb and working with that, but I appreciate you sharing! :)
abergerSRS commentedon May 17, 2021
I too experienced this error. I found that the
validate_nb()method in "utils.py" is searching the within notebook'skernelspecdictionary for the dictionary keylanguage. My particular notebook did not have this key. It only hasnameanddisplay_name, which would need to be further parsed to determine thatlanguage_name == 'python'abergerSRS commentedon May 20, 2021
It looks like pull request #51 will fix this issue
davidleejy commentedon Sep 15, 2021
It would seem that this issue is still present on Google Colab. PR #51 doesn't seem to have been merged. The latest commit on main branch in this repo was on Oct 2017. To anyone reading this, I think this repo may not be active at the moment.
Versions:
Python 3.7.11
ipynb 0.5.1
Example:
gives:
felipewhitaker commentedon Oct 27, 2021
(probably not recommended)
Following on @abergerSRS answer, I looked at what the
utils/validate_nb(nb)function was doing and a quick (and certainly dirty) fix is open the ipynb metadata (open it using notes, for example) addinglanguageto a dict like below.I do not know why this check is being made, and I am unaware of possible side effects. Therefore, I do not responsibilize myself if something goes wrong.
#8 Add `"language": "python"` to kernelspec metadata so this notebook…