Google Colab : ModuleNotFoundError: No module named 'base_positioner'
This could happen if you haven't mounted your Drive on Colab to the backend properly and also possibly if your file layout in Drive is distinct from the file layout in Colab. Are you running the import command without running the following code?
from google.colab import drive
drive.mount('/content/gdrive')
%cd /content/gdrive/My Drive
If you are doing that then this won't work, as this is a pre-requisite for the mounting to take place (i.e. not running the cells sequentially). You can also try restarting Google Colab and this often fixes any strange errors.
Update:
As you mentioned, the import error likely happens due to its configuration in the main file (i.e. it requires the file to be in the .py
format to be imported just as import base_positioner
).
To import .ipynb
extension file you will need to follow the following process:
If you want to import A.ipynb
in B.ipynb
write
import import_ipynb
import A
The import_ipynb
module can be installed via pip or any other relevant ways.
pip install import_ipynb
Colab error : ModuleNotFoundError: No module named
Your file layout in Drive is distinct from the file layout in Colab.
In order to use Drive files in Colab, you'll need to mount your Drive on the Colab backend using the following snippet:
from google.colab import drive
drive.mount('/content/drive')
Then, if you have a file like mylib.py
, you'll want to %cd /content/drive
in order to change your working directory. Then, you can import mylib
.
Here's a complete example:
https://colab.research.google.com/drive/12qC2abKAIAlUM_jNAokGlooKY-idbSxi
ModuleNotFoundError in Colaboratory
Try to replace your running command with:
!python -m property_prediction.predict
Or better:
from property_prediction.predict import predict # or whatever your main function is called
predict()
NB: This is of course assuming that you have a module named GP in the folder project_folder
If none of this work, you might be interested in reading this or other articles about imports with python (this is most likely not a problem of google collab)
Related Topics
What Is the Correct Way to Make My Pyqt Application Quit When Killed from the Console (Ctrl-C)
Pandas: Update Column Values from Another Column If Criteria
How to Change the Foreground or Background Colour of a Tkinter Button on MAC Os X
Cv2 Image Error: Error: (-215:Assertion Failed) !Ssize.Empty() in Function 'Cv::Resize'
Python Anaconda - How to Safely Uninstall
Python3 Tkinter Set Image Size
How to Count the Number of Files in a Directory Using Python
Python Replace Single Quotes Except Apostrophes
How to Export a Table Dataframe in Pyspark to Csv
Beautifulsoup Findall() Given Multiple Classes
Pandas To_Csv: Suppress Scientific Notation in CSV File When Writing Pandas to Csv
How to Get a Fields Particular Value of Json in Python
How to Test If a Column Exists and Is Not Null in a Dataframe
How to Convert Float into Hours Minutes Seconds
How to Pad a String With Leading Zeros in Python 3
Python - How to Separate Paragraphs from Text
Hiding Raw_Input() Password Input
Using Opencv to Overlay Transparent Image Onto Another Image