BrooklynSon
BrooklynSon

Reputation: 2103

from IPython.display import GeoJSON not working on google colab

On Google Colab I'm getting an error when trying to import GeoJSON from IPython.display:

enter image description here

Any help on how to properly import it would be appreciated.

Upvotes: 3

Views: 4048

Answers (3)

JaonHax
JaonHax

Reputation: 346

Google Colaboratory has an older version of IPython installed (v5.5.0 as of the time I'm writing this). The best way to fix this is to include the following line in the Colab notebook before your import statements:

!pip3 install --upgrade IPython

This should fix it for you!

Upvotes: 0

BrooklynSon
BrooklynSon

Reputation: 2103

Exactly how to execute in Google Colab:

  1. import IPython
  2. Update IPython
  3. Now able to from IPython.display import GeoJson

enter image description here

Upvotes: 2

InsertCheesyLine
InsertCheesyLine

Reputation: 1373

I found the issue to be caused by your Collab runtime having an older version of IPython installed.

pip freeze

Output

ipython==5.5.0
ipython-genutils==0.2.0
ipython-sql==0.3.9
ipywidgets==7.5.1

Since the collab was created sometime ago

Updating the module fixed the issue for me

pip install -U IPython 

After which you can restart your runtime and the changes should be reflected

pip freeze

Output

ipython==7.16.1
ipython-genutils==0.2.0
ipython-sql==0.3.9

Upvotes: 3

Related Questions