install tensorflow from jupyter notebook - tensorflow

I'm trying to install tensorflow from Jupyter notbook. Any reason the blow seems to be hung up.
The code I used to install it is:
conda install -c conda-forge tensorflow

Create virtual environment for Tensorflow
#create virtual environment tf and install python
conda create -n tf python=3.9
#activate virtual env
activate tf
#install tensorflow
pip install tensorflow
#install Jupyter notebook
pip install jupyter
#Launch notebook
jupyter notebook
OR.
Jupyter notebook is available then just run !pip install tensorflow on jupyter notebook

Related

Cannot start jupyter notebook with tensorflow on M1 mac

To get tensorflow working on an M1 mac I installed anaconda navigator, and then followed these instructions:
install miniforge, and then
tensorflow-deps
tensorflow-macos
tensorflow-metal
Installing these packages did not give any errors, but when I try to launch a Jupyter notebook from the Anaconda Navigator interface I get this error
ImportError: dlopen(/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so, 0x0002): tried: '/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
It seems that _device.cpython-38-darwin.so is not ready for M1 ? Is this a bug?
How can I get tensorflow working on the M1 mac? (with a jupyter notebook). Note: I did get Jupyter notebook working with python in general, just not with tensorflow).
It seems you have installed miniforge 'x86_64' file whereas you need 'arm64' as shown in the ImportError message.
Please try again by installing miniconda macOS (Miniconda3 macOS Apple M1 64-bit bash) package and run below code step by step in the terminal to access the tensorflow with jupyter notebook:
Download the miniconda package, open the terminal and cd to the
download directory to access the miniconda.sh file
cd downloads
bash <the_downloaded_package.sh> - agree(yes) to the License terms and confirm the miniconda installation directory.
cd to the installed miniconda directory and create conda virtual environment for tensorflow
conda create --name tf python=3.9
conda activate tf
Now install TensorFlow using
pip install --upgrade pip
python -m pip install tensorflow #or
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
To verify if tensorflow installed, type:
python (enter)
>>import tensorflow as tf
>>tf.__version__
Install and open the jupyter notebook.
conda install jupyter
jupyter notebook

How to access to tensorflow from Jupyter notebook?

I installed tensorflow 2.0 from source, following the official instructions: https://www.tensorflow.org/install/source
It works when I access from python console (Outside of tensorflow folder), I want to get access from Jupyter notebook.
I copied tensorflow's folder to:
/home/kati/anaconda3/pkgs/tensorflow
but still not working
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-d6579f534729> in <module>
----> 1 import tensorflow
ModuleNotFoundError: No module named 'tensorflow'
System Info
Ubuntu 18.04.3
jupyter core : 4.5.0
jupyter-notebook : 6.0.0
Here are the steps:
Download Anaconda
Create a virtual environment and activate it
Install K̵e̵r̵a̵s̵ ̵a̵n̵d̵ TensorFlow etc.
Launch Jupyter Notebook
Since you already have Jupyter Notebook, you will need to create an env variable, install tensorflow and keras. Commands are mentioned below:
update conda in your default environment
$ conda upgrade --all
create a new environment with conda
$ conda create -n [my-env-name] python=[python-version]
activate the environment you created
$ source activate [my-env-name]
install pip in the virtual environment
$ conda install pip
install Tensorflow CPU version
$ pip3 install --upgrade tensorflow # for python 3.*
install Keras (Note: please install TensorFlow first)
$ pip install Keras
remove an environment
$ conda env remove --name [my-env-name]
Install pip package and then you can just use "pip install [package name]" command to install any package easily.
Did you start running jupyter notebook from the virtual environment which you installed tensorflow?
Also you don't need to copy tensorflow to anaconda3 folder it's better to install by using pip or anconda navigator.
pip install tensorflow
Reference:
https://pypi.org/project/tensorflow/

how to fix no module name tensorflow in jupyter notebook

I am facing the problem where tensorflow is not running in the jupyter notebook it is showing me
No module named tensorflow
But it is running ine anaconda prompt how to fix this
Personally I would try it this:
First create a new environment:
conda create -n test_tensor
Second we can activate that enviornment now that we created using the source command:
source activate test_tensor
Then we can install pip:
conda install pip
The we can installTensorFlow
pip install --upgrade tensorflow
These links could help also:
Trouble with TensorFlow in Jupyter Notebook
Running Tensorflow in Jupyter Notebook

tensorflow is only available in virtual env in anaconda

I installed tensorflow-gpu in anaconda3.
The steps I followed are:
conda create -n tensorflow pip python=3.6
source activate tensorflow
pip install tensorflow_gpu-1.8.0-cp36-cp36m-linux_x86_64.whl
After these steps, I find that if I use the python and ipython in anaconda3/bin, I can't import tensorflow (no module named tensorflow)
But If I activate the environment of tensorflow or I use the python and ipython in anaconda3/env/tensorflow/bin, I can import tensorflow.
And there is also no directory for tensorflow inanaconda3/lib/python3.6/site-package
Anyone knows why?
You created a conda environment and installed Tensorflow to that environment. Therefore you can only use Tensorflow inside that environment.
If you wish to use Tensorflow outside of an environment then don't activate the environment you created and just pip install Tensorflow.

tensorflow installation error in Window + anaconda

i tried to install tensorflow in my anaconda by creating a virtual env
conda create -n tensorflow python=3.5
but after i type y, nothing happened. How can i fix this?
So what you did is creating an environment called tensorflow, you need to install it as well
you can do either
conda install tensorflow
or
pip install tensorflow