how do you import my own module on colab? - python

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.

Related

Why does the pattern package fails to be imported in jupyter notebook yet it is already installed

I installed pattern3 in the cmd with: pip install pattern3
and it was successful I also installed in the jupyter notebook and still it was successful.
However, when I try to import it with import patterns I get this error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2116/1948699844.py in <module>
----> 1 import patterns
ModuleNotFoundError: No module named 'patterns'
I think you have made a typo. The import statement for the pattern3 module would be import pattern3, not import patterns.
If you have installed the pattern3 module correctly, you should be able to import it by using the new statement.

ImportError: cannot import name 'RasaNLUConfig' from 'rasa_nlu.config' in Google Colaboratory

I'm trying to make a NLU model. When I run
from rasa_nlu.config import RasaNLUConfig
I get an error:
ImportError Traceback (most recent call last)
<ipython-input-1-c2bca1b53b6f> in <module>
----> 1 from rasa_nlu.config import RasaNLUConfig
2 from rasa_nlu.model import Trainer
ImportError: cannot import name 'RasaNLUConfig' from 'rasa_nlu.config' (/usr/local/lib/python3.7/dist-packages/rasa_nlu/config.py)
I thought, "Meh,not a big issue, Colaboratory just hasn't got Rasa installed by default, I'll just install it".
So when I installed it with !pip install rasa_nlu, it did everything, and then it told me to restart the runtime and gave me a button to do that. I did that, then I ran from rasa_nlu.config import RasaNLUConfig and I still get the same error:
ImportError: cannot import name 'RasaNLUConfig' from 'rasa_nlu.config'
I am not familiar with !apt so I don't know how I'm supposed to install Rasa with that. Will the problem be solved with that? Or is it something else?
Looks like I was using a newer version of rasa_nlu (0.15.1). The tutorial I was following used 0.11.3. In 0.11.3, RasaNLUConfig was located at from rasa_nlu.config. But in 0.15.1, it was someplace else.
So... that's solved!

Importing library Utils

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.
---------------------------------------------------------------------------

Importing a python module into colab - ModuleNotFoundError

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.
---------------------------------------------------------------------------

Can't import zipline.transforms

I'm trying to import zipline.transforms, but the output message says No module named transforms. I'm using python2.7 and downloaded zipline via conda.
from zipline.transforms import batch_transforms
ImportErrorTraceback (most recent call last)
<ipython-input-55-253f85965feb> in <module>()
----> 1 from zipline.transforms import batch_transform
ImportError: No module named transforms
First, is your IDE (pycharm or sublime) included Anaconda in the path? Second, please check where you zipline module was installed, usually .../lib/python2.7/site-packages/zipline, does it include a module called "transforms"? maybe it's an old module, not in the updated zipline anymore.

Categories

Resources