cnn_utils module missing from Google Colab - python

I'm trying to run a copy of a notebook from my Coursera class (which is in Jupyter) in Colab and getting an error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-1ee14f68a167> in <module>()
8 import tensorflow as tf
9 from tensorflow.python.framework import ops
---> 10 from cnn_utils import *
11
12 get_ipython().magic('matplotlib inline')
ModuleNotFoundError: No module named 'cnn_utils'
i tried doing !pip install but it yelled at me again:
Could not find a version that satisfies the requirement cnn_utils (from versions: )
No matching distribution found for cnn_utils
anyone know how to fix it?

cnn_utils here is just a personal library for the course, not a public module. You cannot install it with pip install.
You need to find the source of cnn_utils.py then download that to your computer, then upload it to Colab.

here is the cnn_utils.py from coursera course

Related

Cannot import PyTorch/XLA for using TPU in CoLab with ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found

I want to use TPU to run a PyTorch program on Google Colab, and I installed PyTorch/XLA in my CoLab notebook by using this code:
!pip install cloud-tpu-client==0.10 torch==1.12.0 https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-1.12-cp38-cp38-linux_x86_64.whl
Then, I successfully imported pytorch by
import torch.
But, when I tried to import torch_xla by using import torch_xla, I got this error message:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-7fe098b5b807> in <module>
----> 1 import torch_xla
/usr/local/lib/python3.8/dist-packages/torch_xla/__init__.py in <module>
99 from ._patched_functions import _apply_patches
100 from .version import __version__
--> 101 import _XLAC
102
103
ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /usr/local/lib/python3.8/dist-packages/torch_xla/lib/libxla_computation_client.so)
---------------------------------------------------------------------------
The version of Python is Python 3.8.15.
I thought that perhaps downgrading the Python version to Python 3.7 might help, but is there a solution that does not need to downgrade the Python version?
https://storage.googleapis.com/tpu-pytorch/wheels/tpuvm/torch_xla-1.12-cp38-cp38-linux_x86_64.whl doesn't look like the correct colab wheel.
If you plan to run the colab on TPU, can you try the command !pip install cloud-tpu-client==0.10 torch==1.13.0 https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-1.13-cp38-cp38-linux_x86_64.whl instead?

Cannot import pycaret in google colab

I cant import pycaret in a google colab
Here are all the steps I had taken:
Change python version to 3.8
Installed pip
I then ran
!pip install pycaret
import pycaret
the install works, but then
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-27-fdea18e6876c> in <module>
1 get_ipython().system('pip install pycaret ')
----> 2 import pycaret
ModuleNotFoundError: No module named 'pycaret'
I must be doing something very wrong!
In troubleshooting I also pip installed numpy and pandas which both imported just fine
For importing use this, this is one is for classification:
from pycaret.classification import *
And for regression:
from pycaret.regression import *
For NLP:
from pycaret.nlp import *
!pip install pycaret
should work without any issues. I have used it multiple times on Google Colab. Alternately, you can use
pip install --pre pycaret

env.render() in Jupyter Notebook hangs up [duplicate]

I´m trying to run some code using Jupyter and I can´t find a way of installing gym.
This is the code:
!pip install gym==0.18
import gym
After all the "Requirement already satisfied"s (since I had already installed it) it says:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [2], in <cell line: 2>()
1 get_ipython().system('pip install gym')
----> 2 import gym
ModuleNotFoundError: No module named 'gym'
The same happens if I don´t specify a version, and use only "gym".
I tried installing it using Terminal several ways, however, this shouldn´t be so complicated, right?
Please help.
Thanks in advance.

ModuleNotFoundError: No module named 'pyaudio' in Google Colab

I imported 'pyaudio' library in Google Colab, but ModuleNotFoundError occurs.
However, it worked just a week ago... :( But does not Now..
I tried to re-install pyaudio in colab with the next codes but same errors occur.
!sudo apt-get install python-pyaudio
!pip install pyaudio
How can I do?
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-13-627d880c2452> in <module>()
4 from pydub.effects import normalize
5
----> 6 import pyaudio
7 import scipy.signal
8
ModuleNotFoundError: No module named 'pyaudio'
---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------

ImportError: No module named caffe

I am trying to run Google Research's DeepDream code on a mac running OSx 10.9.5.
There are a few dependencies that I had to install. I am using the Anaconda distribution of python and I made sure that I have all the packages required.
The hardest thing was to install Caffe. I have ATLAS installed using fink. Then I have compiled caffe and pycaffe. When I ran 'make runtest' all tests passed. I also ran 'make distribute'.
When I run the notebook released from Google, I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-8200bcb1df23> in <module>()
7 from google.protobuf import text_format
8
----> 9 import caffe
10
11 def showarray(a, fmt='jpeg'):
ImportError: No module named caffe
How can this be? What can I try to do to fix it?

Categories