Import tensorflow error, no module named tensorflow in Google cloud - tensorflow

Remotely connected to my gcloud vm (compute engine) using ssh through gcloud sdk shell and putty.
Created a sample python script as per the quickstart:
https://cloud.google.com/tpu/docs/quickstart
Trying to run the script but getting error no module named tensorflow.
Have both python 2.7.14 and 3.5.4 installed locally. I can run python scripts locally but not in the gcloud shell.
Any help is greatly appreciated
Thanks

TensorFlow packages have to be installed if you want to use them.
First you have to install pip if you haven't done so already:
sudo apt-get update
sudo apt-get -y upgrade \
&& sudo apt-get install -y python-pip python-dev
When you have pip installed you have to install the TensorFlow packages:
sudo pip install tensorflow
You can follow step by step tutorial how to set up VM instance with TensorFlow in Google Cloud here

Related

HadoopFileSystem load error during TensorFlow installation on raspberry pi3

screen shot
As Python2.7 will be deprecated on 01/01/2020. I was planning to start using python3. So, I tried to install the tensorflow==1.14.0 on the raspberry pi and it was successful, but when I am loading the Tensorflow for further operations then it throws a load error.
Python - 3.7 (Default installed by Raspbian OS)
Any suggestions why am I facing this issue?
Thanks for your time
You can't install later versions of Tensorflow on the Raspberry Pi using pip. You have to install from source. I made a video doing this: https://youtu.be/GNRg2P8Vqqs
Installing Tensorflow requires some extra steps on the Pi's ARM architecture.
This is how I installed tf 2.0 on my Pi 4:
Make your project directory:
cd Desktop
mkdir tf_pi
cd tf_pi
Make a virtual environment:
python3 -m pip install virtualenv
virtualenv env
source env/bin/activate
Run the commands based on https://github.com/PINTO0309/Tensorflow-bin/#usage:
sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev
python3 -m pip install keras_applications==1.0.8 --no-deps
python3 -m pip install keras_preprocessing==1.1.0 --no-deps
python3 -m pip install h5py==2.9.0
sudo apt-get install -y openmpi-bin libopenmpi-dev
sudo apt-get install -y libatlas-base-dev
python3 -m pip install -U six wheel mock
Pick a tensorflow release from https://github.com/lhelontra/tensorflow-on-arm/releases (I picked 2.0.0). Picking a higher version of Tensorflow (like 2.1.0) requires a higher version of scipy that wasn't compatible with my Raspberry Pi:
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.0.0/tensorflow-2.0.0-cp37-none-linux_armv7l.whl
python3 -m pip uninstall tensorflow
python3 -m pip install tensorflow-2.0.0-cp37-none-linux_armv7l.whl
RESTART YOUR TERMINAL
Reactivate your virtual environment:
cd Desktop
cd tf_pi
source env/bin/activate
Test:
Open a python interpreter by executing:
python3
import tensorflow
tensor.__version__
This should have no errors and output: 2.0.0
I got the same issue today when trying to run the fresh tf installation on my pi 3+

Can't install Rasa on Ubuntu 18.04 + Python 3.7.5?

I have succeed to install Rasa NLU on my Win 10 with python 3.7 but couldn't do this on Ubuntu 18.04.
Please help.
Here is the error I get:
pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
Could not find a version that satisfies the requirement
tensorflow~=1.15.0 (from rasa~=1.5.1->rasa-x) (from versions:
1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1) No matching distribution found for tensorflow~=1.15.0 (from rasa~=1.5.1->rasa-x)
Please advise what is the difference to my Win10 machine?
Please advise how can I install it.
I had followed these following steps and it's working fine for me for ubuntu 18.04 + Python3
Firstly create directory name of your choice and get inside of it
mkdir rasaprojects #directory name of your choice in place of rasaprojects
cd rasaprojects #get inside that directory
Now create virtual environment of python3
virtualenv rasaenv -p python3 #write your environment name instead of rasaenv
Now activate the environment
source rasaenv/bin/activate
Now you are good to go with rasa installation
pip3 install rasa
Updating your pip version should solve the issue. I believe TensorFlow and your current pip version don't go well together.
Do this:
Download pip installer python script from here.
Run it using python get-pip.py
Another thing is that TensorFlow was not supported by python3.7 untill recently. So if the first solution doesn't work you can try downgrading python to python3.6
Upgrade pip before instaling rasa.
pip3 install --upgrade pip

Installing Tensorflow 1.3 (No module named tensorflow)

I am initializing a new VM with Ubuntu 17 on Google Cloud Platform, I then SSH into the newly created VM, upload this script and run it...
#! /bin/bash
sudo apt-get install python-pip
sudo pip install --upgrade pip
sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Now, this works for me, when I launch a Python interactive environment
import tensorflow as tf
does not throw an error, however, if I run the same script but replace
tensorflow-0.5.0-cp27-none-linux_x86_64.whl
with
tensorflow-1.3.0-cp27-none-linux_x86_64.whl
I get:
ImportError: No module named tensorflow
... incredibly frustrating, especially since the contrib library doesn't seem to be apart of the 0.5 version... any ideas of what is going on, perhaps how I can first install 0.5 and then upgrade to 1.3 ?
I also get the same then i tried pip install tensorflow after worked fine

Unable to install Tensorflow cpu version in Ubuntu16.04 using anaconda

I am facing a problem while installing Tensorflow in Ubuntu 16.04. I was trying to install Tensorfilow CPU supportable version using Anaconda. This is the error I got
'tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl is not a supported wheel
on this platform.'
Can any one help me to solve this problem.
Try following steps:
First (if you haven't already) install Pip
For Python 2.X
sudo apt-get install python-pip python-dev python-virtualenv
For Python 3.X
sudo apt-get install python3-pip python3-dev python-virtualenv
Switch to your Conda environment:
source activate your_environment_name
And install TensorFlow using Pip:
For Python 2.X
pip install tensorflow
For Python 3.X
pip3 install tensorflow

Getting permission denied error while installing tensorflow and keras

After following the steps from my previously asked question Can I implement deep learning models in my laptop with intel hd graphics
I am getting a permission denied error while installing tensorflow
What can I do to install tensorflow and keras without getting this error?
pip3 is trying to access /usr/bin/ for which you need superuser rights. Try
sudo pip3 install --upgrade ...
It appears that TensorFlow depends on a newer version of the setuptools package than you have installed. As Maximilian points out, pip needs root access to upgrade setuptools and install TensorFlow and Keras in your machine's Python distribution. You can either use sudo as he suggests, or it may be safer to install TensorFlow into a Virtualenv. For example, to create a Virtualenv in the directory ~/tensorflow, execute the following commands:
$ sudo pip install virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ cd ~/tensorflow
$ source bin/activate
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0-cp27-none-linux_x86_64.whl