ImportError: cannot import name 'basemaps' from 'geemap.basemaps' (/usr/local/lib/python3.7/dist-packages/geemap/basemaps.py) - google-colaboratory

Using Google Colab Unable to install basemap to Colab
pip install geemap
import google.colab
import geemap.eefolium as geemap
import os
import geemap
import ee
ee.Authenticate()
ee.Initialize()
!apt-get install -q libgeos-3.5.0
!apt-get install -q libgeos-dev
!pip install -q https://github.com/matplotlib/basemap/archive/master.zip
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
%matplotlib inline
import geemap.basemaps
from geemap.basemaps import basemaps
ImportError Traceback (most recent call last)
in ()
----> 1 from geemap.basemaps import basemaps
ImportError: cannot import name 'basemaps' from 'geemap.basemaps' (/usr/local/lib/python3.7/dist-packages/geemap/basemaps.py)

Related

'CRF' object has no attribute 'keep_tempfiles'

I have imported `
from itertools import chain
import nltk
import sklearn
import scipy.stats
import sklearn_crfsuite
from sklearn_crfsuite import scorers,CRF
from sklearn_crfsuite.metrics import flat_classification_report
from sklearn_crfsuite import metrics`
Is there any way we can fix this on google colab?
Try this:
!pip install scikit-learn==0.22.2 --user
source: https://github.com/TeamHG-Memex/sklearn-crfsuite/issues/60

ImportError: cnot import - 'kneeLocator' from 'kneed' (/usr/local/lib/python3.7/dist-packages/kneed/__init__.py)

I install(pip install kneed) the Kneed, but when I re-run the Import again but it keeps showing me the error(Colad)
pip install kneed.
2.from kneed import kneeLocator(Error).
ImportError: cannot import name 'kneeLocator' from 'kneed' (/usr/local/lib/python3.7/dist-packages/kneed/init.py)

AttributeError: module 'torch.jit' has no attribute '_script_if_tracing'

import detectron2
from detectron2.utils.logger import setup_logger
setup_logger()
# import some common libraries
import numpy as np
import cv2
import random
from google.colab.patches import cv2_imshow
import matplotlib.pyplot as plt
# import some common detectron2 utilities
from detectron2 import model_zoo
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2.utils.visualizer import Visualizer
from detectron2.data import MetadataCatalog
AttributeError Traceback (most recent call last)
<ipython-input-3-fa7489d52c2b> in <module>()
12 # import some common detectron2 utilities
13
---> 14 from detectron2.engine import DefaultPredictor
15 from detectron2.config import get_cfg
16 from detectron2.utils.visualizer import Visualizer
15 frames
/usr/local/lib/python3.6/dist-packages/torchvision/ops/boxes.py in <module>()
43
44
---> 45 #torch.jit._script_if_tracing
46 def batched_nms(
47 boxes: Tensor,
AttributeError: module 'torch.jit' has no attribute '_script_if_tracing'
In my case using pip install torchvision==0.7.0 instead of torchvision==0.7.0+cpu solved the error.

Colab ImportError: cannot import name 'squeeze_or_expand_dimensions'

following Transfer Learning with TensorFlow Hub for TFLite tutorial,fisrt step is
!pip install -q -U "tensorflow-gpu=2.0.0b1"
setup:
import os
import matplotlib.pylab as plt
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__version__)
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
an error raised:ImportError: cannot import name 'export_saved_model'
after i tried
%tensorflow_version 2.x
!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.14.0
according to this answer, another error raised:
ImportError: cannot import name 'squeeze_or_expand_dimensions'
also,i tried !pip install --upgrade tensorflow,and another error raised...ImportError: cannot import name 'collections_abc'
i'm stuck here...
Don't run !pip install -q -U "tensorflow-gpu==2.0.0b1".
Under "Runtime" menu "Change runtime type" to "GPU" and "Factory reset runtime".
import os
import matplotlib.pylab as plt
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__version__)
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
Output:
Version: 2.2.0
Eager mode: True
Hub version: 0.8.0
GPU is available

ModuleNotFoundError for .vision and .utils , download_url, VisionDataset

I am trying to create a custom dataset in google colab, but imports give me errors.
from PIL import Image
from six.moves import zip
import os
from .vision import VisionDataset ------------------------(1)
from .utils import download_url, check_integrity --------------(2)
class datasetName(VisionDataset):
...
(1) error :
ModuleNotFoundError: No module named 'main.vision'; 'main' is
not a package
(2) error :
ModuleNotFoundError: No module named 'main.utils'; 'main' is
not a package
I have tried to add from torchvision import utils but it does not solve the error.
If I change to from torch.utils import download_url, check_integrity
then the error becomes:
ImportError: cannot import name 'download_url'
Please try the following import lines.
from torchvision.datasets.vision import VisionDataset
from torchvision.datasets.utils import download_url, check_integrity
Hope it helps!