ModuleNotFoundError: No module named 'tensorflow_data_validation' in Google Colab - python

I tried to import Tensorflow Data Validation library via the below command in Google Colab.
import tensorflow_data_validation as tfdv
It gave me this error:
ModuleNotFoundError: No module named 'tensorflow_data_validation'
I tried to install the library using pip via below commands. But couldn't install the package successfully.
pip install tensorflow-data-validation
pip install tensorflow-data-validation==1.3.0
pip install --upgrade --force-reinstall tensorflow-data-validation[all]
How to resolve this issue?

To install the library properly, follow these steps:
Install the library using pip:
!pip install tensorflow-data-validation
Reload the environment. A button will show up at the end of the previous cell to Restart, but you can also do it with Ctrl+M or using the menu: "Runtime" > "Restart Runtime".
Import the library as usual:
import tensorflow_data_validation as tfdv
Why do I need to reload the environment? It's because installing tensorflow-data-validation upgrades one of the libraries already present in your Colab environment. So, to "activate" the new environment and use the newly installed libraries and their installed versions you need to reload the environment

I was able to resolve this error by installing tensorflow_data_validation library via the below command. Now I'm able to use this library in my Colab file.
!pip install -U tensorflow \
tensorflow-data-validation \
apache-beam[gcp]

Related

ModuleNotFoundError: No module named 'kmodes'

I have tried installing it using pip install kmodes and it says that "Requirement is satisfied" but am not being able to import the library even after that.
The list of libraries doesn't have kmodes even after installing. Attaching screenshot for reference. What is happening here?
from kmodes.kprototypes import KPrototypes
ModuleNotFoundError: No module named 'kmodes'
Maybe your PIP is installing to the wrong version of python and the code you are running is being interreted by a later version
Try copying your python executable path and running this
C:\Users\username\AppData\Local\Programs\Python\Python39\python.exe -m pip install kmodes
Another reason is that kmodes did not install properly the first time
Try running this as an administrator
pip uninstall kmodes && pip install kmodes

Install module by apt-get, cannot import python package

I am trying to install minieigen python3 package in google colab.
I've been trying to install it through pip but there is lot of dependancies and after few hours of trying figure out what else is missing, I just gave up.
There is second option to install it using apt-get - apt-get install python3-minieigen. That one is fine, but I cannot import it in python later on. I've checked sys.path and it looks ok. Here is screenshot with path of installed package and sys.path.
Here is the snippet with commands that I am using:
!apt-get install python3-minieigen
!pip install minieigen
import minieigen
import sys
sys.path
I would appreciate any way of installing this package on google colab.

i can't import tensorflow in python

I had install TensorFlow using pip and it has been installed successfully but when I am trying to import it is giving me an error "ImportError: No module named '_pywrap_tensorflow_internal" Failed to load the native TensorFlow runtime.
How can I fix it?
Error Screenshot here
Use python version Python 3.8.8 or above :
pip install --user virtualenv
Activate your virtual enviroment and type the command in your console
pip install tensorflow
pip3 install tensorflow
Tensorflow package is of something around 200mb or above so be patient and let it to be install

How to install shogun library on Google Colaboratory

I want to use some tools from shogun machine learning library through Google Colab. However, I cannot install the package. I tried to install Anaconda and install shogun using conda, but after installation, importing shogun is unsuccessful. I tried to follow the instructions provided by the shogun official website, though it didn't help.
So, my question is how to install shogun in a Google Colab document? Is it possible in the first place?
You can first install anaconda on colab,
!wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh && bash Anaconda3-5.2.0-Linux-x86_64.sh -bfp /usr/local
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
Then, install Shogun with,
!conda install -c conda-forge shogun
You can install packages in Google Colab using the the following syntax:
!pip install shogun-ml
However, on the shogun-ml installation page they list the other installation options they have available:
Install via atp-get:
!add-apt-repository ppa:shogun-toolbox/stable
!apt-get update
!apt-get install libshogun18
Then install the python 2 bindings with:
!apt-get install python-shogun
Install via docker:
!docker pull shogun/shogun:master
!docker run -it shogun/shogun:master bash
Additionally this dockerfile would be appropriate:
https://hub.docker.com/r/shogun/cloud/~/dockerfile/

ImportError: No module named 'google'

I installed Python 3.5. I ran the pip install google command and verified the modules. Google was present.
I installed Anaconda 3.5 and tried to run z sample code. But I'm getting the import error. Please find the screen shot attached.
What am I missing? Do I have to link my Spyder to Python installation directory in some way? Why is Spyder unable to google module?
My Python installation directory: C:\Users\XXX\AppData\Local\Programs\Python\Python35
My scenario is a bit different and I could not find a solution from similar posts here.
According to https://github.com/googleapis/google-api-python-client#installation, you need to install the google-api-python-client package:
pip install --upgrade google-api-python-client
Use this both installation and then go ahead with your Python code:
pip install google-cloud
pip install google-cloud-vision
I could fix it by installing the following directly.
pip install google.cloud.bigquery
pip install google.cloud.storage
I faced the same issue, and I was trying to import translate from google.cloud, but I kept getting the same error.
This is what I did
pip install protobuf
pip install google-cloud-translate
And to install the storage service from google google-cloud-storage, it should be installed separately.
Ref - https://cloud.google.com/python/
Kindly executing these commands,
pip install google
pip install google-api-core
will definitely solve your problem.
I figured out the solution:
I had to delete my Anaconda and Python installations
Re-install Anaconda only
Open the Anaconda prompt and point it to Anaconda/Scripts
Run pip install google
Run the sample code now from Spyder.
No more errors.
I solved the problem in this way:
sudo pip install conda
pip install google
The error got resolved.
I got this from cloud service documentation:
pip install --upgrade google-cloud-translate
It worked for me!
I found a similar error when I tried to access the bigquery from google.cloud.
from google.cloud import bigquery
The error was resolved after I installed the google.cloud from conda-forge community.
conda install -c conda-forge google-cloud-bigquery
I had a similar import problem. I noticed that there was no __init__.py file in the root of the google package. So, I created an empty __init__.py and now the import works.
For Python-Flask application.
If nothing helps,
Uninstall flask (pip uninstall flask)
Uninstall python from your machine
Restart the machine and make sure uninstall is done properly
Re-install python and flask again
Run pip install --upgrade google-api-python-client
Run your application
It should be working fine now.
What solved it for me was uninstalling Anaconda (in my case, Spyder), install the required google clients (google-api-python-client will do), then reinstall Anaconda.
This should solve it!
I know its frustrating to make it done. Its not hit and try to be honest.
first step to setup google apis
pip install --upgrade google-api-python-client
second- look and read your DAG and see what is source/destination or other GCP platform you are using such as if you are taking data from bigquery then
pip install bigquery
or pip install xyz-google-stuff
I too had the same error while trying vision API
from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()
got no module named 'google'
so I added a line
import google
in such a way,
import google
from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()
and it worked for me.:)
Close Anaconda/Spyder
Open command prompt and run the below command
conda update --all
Start the app again and this time it should work.
Note - You need not have to uninstall/reinstall anything.
Kindly executing these commands
If you are using the python2 version:
pip install google
pip install google-api-core
If you are using the python3 version:
pip3 install google
pip3 install google-api-core
will definitely solve your problem.

Categories