How to install shogun library on Google Colaboratory - python

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/

Related

ModuleNotFoundError: No module named 'tensorflow_data_validation' in Google Colab

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]

How can I install a library (cfgrib) in databricks through conda?

I'm trying to install cfgrib (https://pypi.org/project/cfgrib/) on databricks.
Cfgrib depends only on the c-library eccodes.
I installed both eccodes and cfgrib through the libraries page of databricks.
However, when I do "import cfgrib", it keeps on saying:
"Cannot find the ecCodes library"
On cfgrib package page, they say the best way to install it is via conda with:
$ conda install -c conda-forge cfgrib
Months ago with an older runtime version of the cluster (that I don't have anymore) I managed to install it throgh conda writing direcly on the databricks notebook: "%sh conda install -c conda-forge eccodes"
However when I try to do the same now it keeps running for like 1 hour and doesn't install it.
How can I install it?
Is there a way to install conda libraries on the cluster itself and not in the notebook?
Thank you very much,
(my first question, any feedback is welcomed :)

How to install python dependency when using google-cloud-ml-engine notebook?

I am on google-cloud-ml notebook. Trying to install pandas_ml in order to import it.
I read https://cloud.google.com/ml-engine/docs/notebooks/dependencies tried both options (terminal and a separate installation notebook). None of those solutions work for me
#either
pip install pandas_ml #terminal
#or
!pip install pandas_ml #notebook
Solved!
since I'm using Python 3.5 I had to use pip3 instead of pip
!pip will install your packages on the system level and not in your notebook kernel. Try this instead:
import sys
!{sys.executable} -m pip3 install pandas_ml
Eventually, Google MLE notebooks will support %pip.
More information can be found on Jake VanderPlas's blog: Installing Python Packages from a Jupyter Notebook.

pip - Unable to install Fastai

Whenever I run:
pip install fastai
I get the error
"Command "python setup.py egg_info" failed with error code 1 in C:\Users\seja9890\AppData\Local\Temp\pip-install-_cw7ve61\torch\".
Can someone please guide me where I might be going wrong?
Ps.: I have tried updating setuptools and it doesn't help in my case.
Fastai doesn't work with Python 2 so make sure you installed pip3 (sudo apt install python3-pip on Ubuntu).
Make sure Python3 is at least 3.6 this may change since Fastai may need 3.7. soon.
and then:
pip3 install git+https://github.com/fastai/fastai.git
or use pip3 install fastai, or in some cases you may need:
pip3 install --no-deps fastai
Note: At the moment I am writing this: PyTorch v1 and Python 3.6 are the minimal version requirements.
For official website, you should install it with conda.
anaconda
fast.ai
To install
# Prerequisites
Anaconda, manages Python environment and dependencies
# Normal installation
Download project: git clone https://github.com/fastai/fastai.git
Move into root folder: cd fastai
Set up Python environment: conda env update
Activate Python environment: conda activate fastai
If this fails, use instead: source activate fastai
# Install as pip package (not recommend)
You can also install this library in the local environment using pip
pip install fastai
However this is not currently the recommended approach, since the library is being updated much more frequently than the pip release, fewer people are using and testing the pip version, and pip needs to compile many libraries from scratch (which can be slow).
An alternative is to use the latest Github version with pip
pip install git+https://github.com/fastai/fastai.git

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