8

Getting below validation error on opening my notebook :

{ "metadata": { "trusted": true }, "id": "comparative-import", "cell_type": "code", "source": "import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport nltk\nimport re\nimport gensim \nfrom gensim.utils import simple_preprocess\nfrom gensim.models.word2vec import Word2Vec\nfrom nltk.stem.porter import PorterStemmer\nfrom nltk.corpus import stopwords\nfrom sklearn.decomposition import PCA,TruncatedSVD\nfrom sklearn.manifold import TSNE\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LogisticRegression\nfrom wordcloud import WordCloud, STOPWORDS, ImageColorGenerator\n", "execution_count": 10, "outputs": [] }

Lakshmi R
  • 171
  • 2
  • 8

4 Answers4

10

id is simply not known for notebooks with nbformat below version 4.5.

You can open the notebook file in a text editor and increase the version.

In my case

 "nbformat": 4,
 "nbformat_minor": 4

becomes

 "nbformat": 4,
 "nbformat_minor": 5

For more details https://www.pythonfixing.com/2021/12/fixed-notebook-validation-failed-jupyter.html

Franz Knülle
  • 321
  • 3
  • 5
8

I worked around the above issue by copying the contents of the cell instead of the entire cell (which copies also metadata).

Caution: this does not scale well for large notebooks (every cell has to be handled individually).

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Lakshmi R
  • 171
  • 2
  • 8
2

Try clear the output of all cells of your Jupyter Notebook. In Jupyter Notebook, Goto: cell>All Output>Clear

iqbal
  • 21
  • 2
  • 1
    This actually did the work for me. – phi Aug 22 '22 at 12:52
  • This is the correct solution and should be the accepted answer. It worked for me while I tried to upload my google colab note book onto the Github. This is a gem solution. Thank you very much. – Mainland Apr 16 '23 at 02:32
0

Your notebook is just a bunch of import you can easily recreate it for this time I did it for you :

{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Untitled5.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "CRAF2wibMCRq"
      },
      "source": [
        "import numpy as np \n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "import nltk\n",
        "import re\n",
        "import gensim \n",
        "from gensim.utils import simple_preprocess\n",
        "from gensim.models.word2vec import Word2Vec\n",
        "from nltk.stem.porter import PorterStemmer\n",
        "from nltk.corpus import stopwords\n",
        "from sklearn.decomposition import PCA,TruncatedSVD\n",
        "from sklearn.manifold import TSNE\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.linear_model import LogisticRegression \n",
        "from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}