Skip to content

incorrect version or language #49

Description

@JoyeBright

I have strived to import an external ipynb, but I got the following error:

ImportError: Could not import /content/.ipynb for ipynb.fs.full.: incorrect version or language

I was wondering if I could know that you have ever experienced the same issue, please!

NB: I am running the codes on the Google Colab.

Thanks in advance

Activity

  1. AnupamSaraph commented on Mar 15, 2021

    @AnupamSaraph

    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?

  2. rajkundu commented on Mar 26, 2021

    @rajkundu

    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.

  3. o-inha commented on Mar 26, 2021

    @o-inha

    Btw, my workaround was to use import-ipynb instead.

  4. rajkundu commented on Mar 26, 2021

    @rajkundu

    Ah, thank you - I ended up finding importnb and working with that, but I appreciate you sharing! :)

  5. abergerSRS commented on May 17, 2021

    @abergerSRS

    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'

    "metadata": {
      "kernelspec": {
       "name": "python394jvsc74a57bd0be098d32f57b1a2b9aacbade952c5e427778cda6d97bd24f3e84e87f053b8dae",
       "display_name": "Python 3.9.4 64-bit"
      }
    
  6. abergerSRS commented on May 20, 2021

    @abergerSRS

    It looks like pull request #51 will fix this issue

  7. davidleejy commented on Sep 15, 2021

    @davidleejy

    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:

    # asdf.ipynb
    def foo(a,b):
        print(a,b)
    # abc.ipynb
    !pip install ipynb
    from google.colab import drive
    drive.mount('/content/drive/')
    import sys
    sys.path.append('/content/drive/MyDrive/Colab Notebooks/')
    import ipynb.fs.defs.asdf

    gives:

    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
    
    
  8. felipewhitaker commented on Oct 27, 2021

    @felipewhitaker

    (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) adding language to a dict like below.

    {
      ...
       "metadata": {
         ...
        "kernelspec": {
          ...
         "language": "python" # <--- added line
        }
      ...
    }

    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.

  9. added a commit that references this issue on Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions