How to install tensorflow and keras in jupyter anaconda
You can install TensorFlow and Keras in Jupyter Notebook by using the Anaconda environment by following these steps:
-
Open the Anaconda prompt:
- Windows: Start menu -> Anaconda Prompt
- macOS/Linux: Terminal
-
Create a new conda environment:
conda create -n tensorflow python=3.7
3. Activate the environment:
conda activate tensorflow
4. Install TensorFlow:
conda install tensorflow
5. Install Keras:
conda install keras
6. Launch Jupyter Notebook:
jupyter notebook
7. In Jupyter Notebook, create a new notebook and verify that TensorFlow and Keras have been installed correctly by running the following code:
import tensorflow as tf import keras print(tf.reduce_sum(tf.random.normal([1000, 1000])))
If everything has been installed correctly, you should see the output of the TensorFlow operation without any errors.
Second Method
1. install in a virtual environment Anaconda
Download Anaconda for your platform and choose the Python 3.6 version: https://www.anaconda.com/download
By downloading Anaconda, you get conda, Python, Jupyter Notebook and hundreds of other open source packages.
conda install — installs any software package.
Open Anaconda and then conda shell (CMD.exe Prompt)
2. Install TensorFlow (including Keras)
# install pip in the virtual environment
# install Tensorflow CPU version
$ pip install --upgrade tensorflow # for python 2.7
$ pip3 install --upgrade tensorflow # for python 3.*
# install Keras (Note: please install TensorFlow first)
$ pip install Keras
# invoke python from your shell
$ python
# create a simple TensorFlow program inside the python interactive shell
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
# Exit the python shell
Ctrl+D
You must be logged in to post a comment.