I am working on image classification and using Google colab for this purpose.
But when I want to import the following modules, it throws an error.
from utils import show_test_cases, test_case_checker, perform_computation
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-9-ff42356cc1b5> in <module>()
----> 1 from utils import show_test_cases, test_case_checker, perform_computation
ImportError: cannot import name 'show_test_cases'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Related
I'm working on google colab , and I want to import preprocess_input from tensorflow.keras.preprocessing but this error keeps occurring , while whatever I import from tensorflow work fine except this .
well i'm using tensorflow = 2.8.0
my code :
from tensorflow.keras.preprocessing import preprocess_input
the error :
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-2569fd104ea5> in <module>()
----> 1 from tensorflow.keras.preprocessing import preprocess_input
ImportError: cannot import name 'preprocess_input' from 'tensorflow.keras.preprocessing' (/usr/local/lib/python3.7/dist-packages/keras/api/_v2/keras/preprocessing/__init__.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
what should I install or change to fix this error , i just want to use preprocess_input for model predicting purposes that's all , any suggestions please !
I'm unable to install stackstac on Google Colab. This is reproducible with the code below.
!pip install stackstac
import stackstac
outputs:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c01f370957f7> in <module>()
1 get_ipython().system('pip install stackstac')
----> 2 import stackstac
1 frames
/usr/local/lib/python3.7/dist-packages/stackstac/rio_reader.py in <module>()
5 import threading
6 import weakref
----> 7 from typing import TYPE_CHECKING, Optional, Protocol, Tuple, Type, Union
8
9 import numpy as np
ImportError: cannot import name 'Protocol' from 'typing' (/usr/lib/python3.7/typing.py)
---------------------------------------------------------------------------
Same issue on a local instance how ever that solution doesn't translate.
Protocol was introduced to typing as of Python 3.8, as can be seen in the docs. You appear to be running Python 3.7, based on your file paths - upgrade to use Python 3.8 or later if you can.
I developp on colab and i save my code to create my own module qrl.py on drive but in my qrl.y i use !pip install deplacy and import numpy.
if i try to import the module i have the error following
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-58-62dca1f58066> in <module>()
----> 1 import grl
ModuleNotFoundError: No module named 'grl'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Trying copying the file to /content/ and build your module there. It's not able to access qrl.py (or grl) file.
Im trying to import a colab file as a module with a function (def) to be used in this new colab file.
from google.colab import drive
drive.mount('/content/drive')
I tried all of these calls:
#!cp "drive/My Drive/Colab Notebooks/Aulas_Cursos/test_module" .
!cp '/content/drive/My Drive/Colab Notebooks/Aulas_Cursos/test_module' .
#import sys
#sys.path.insert(0,'/content/drive/My Drive/ColabNotebooks/Aulas_Cursos')
#sys.path.append('/content/gdrive/My Drive')
import test_module
But i got the same error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-42-1a0689a1a9af> in <module>()
----> 1 import test_module
ModuleNotFoundError: No module named 'test_module'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
I am having some difficulty trying to get the linear_algebra module working on Jupyter Notebook in Python. I am trying:
import linear_algebra
But I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-30-7080be6cdc0f> in <module>()
----> 1 import linear_algebra
ImportError: No module named 'linear_algebra'
I don't get what I am doing wrong
Thank you in advanced for help
The 'linear_algebra' is not a library so you can't simply import it as such. It is a file that has the functions (eg. dot) so you have to make sure your main code file and the linear_algebra.py is at the same directory. I hope this helps.