There is no module named tensorflow in jupyter

I have imports in my jupyter laptop, and among them there are tensorflow:

ImportError Traceback (most recent call last) <ipython-input-2-482704985f85> in <module>() 4 import numpy as np 5 import six.moves.copyreg as copyreg ----> 6 import tensorflow as tf 7 from six.moves import cPickle as pickle 8 from six.moves import range ImportError: No module named tensorflow 

I have this on my computer, in a special environment and all related things:

 Requirement already satisfied (use --upgrade to upgrade): tensorflow in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): protobuf==3.0.0b2 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): numpy>=1.10.1 in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): wheel in /Users/mac/anaconda/envs/tensorflow/lib/python2.7/site-packages (from tensorflow) Requirement already satisfied (use --upgrade to upgrade): setuptools in ./setuptools-23.0.0-py2.7.egg (from protobuf==3.0.0b2->tensorflow) 

I can import shadoworflow on my computer:

 >>> import tensorflow as tf >>> 

So, I'm confused, why is this a different situation in a laptop?

+18
source share
10 answers

If you installed TensorFlow as stated in the official documentation: https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#overview

I mean creating an environment called tensorflow and tested your installation in python, but TensorFlow cannot be imported into jupyter, you also need to install jupyter in your tensor flow environment:

 conda install jupyter notebook 

After that, I run jupyter and it can also import TensorFlow:

 jupyter notebook 
+41
source

Jupyter runs in a conda environment where your tenorflow installation is outside of conda. To install tenorflow in a conda virtual environment, enter the following command in your terminal:

  conda install -c conda-forge tensorflow 
+13
source

I had the same problem and solved it by looking at the output:

jupyter kernelspec list

which displays kernel information:

 python2 /Users/Username/Library/Jupyter/kernels/python2 python3 /Users/Username/Library/Jupyter/kernels/python3 

Note that the path points to the Jupyter core for the user. To use it in Anaconda, it should point to the conda env you are using and look something like this: Anaconda3\envs\Env_Name\share\jupyter\kernels\python3 .

So, to remove the Jupyter kernel specification, simply use:

jupyter kernelspec remove python3

or jupyter kernelspec remove python2 if you are using python 2

Now the output of the jupyter kernelspec list should point to the correct kernel.

See https://github.com/jupyter/notebook/issues/397 for more information about this.

+10
source

Here is what I did to fix this problem -

I set shadoworflow for windows using the link below -

https://www.tensorflow.org/install/install_windows

After execution - I activated the tensor flow using the command below -

C:> activate tensor (tensor flow) C:> # Your invitation should change

After execution, I ran below the command -

(tensor flow) C:> conda install notebook

Obtaining package metadata ........... Solution package specifications :.

Environment Installation Package

The following NEW packages are installed:

 bleach: 1.5.0-py35_0 colorama: 0.3.9-py35_0 decorator: 4.1.2-py35_0 entrypoints: 0.2.3-py35_0 html5lib: 0.9999999-py35_0 ipykernel: 4.6.1-py35_0 ---- --- 

jupyter_client 100% | ##################################### | Time: 0:00:00 6.77 MB / s nbformat-4.4.0 100% | ##################################### | Time: 0:00:00 8.10 MB / s ipykernel-4.6. 100% | ###################################### | Time: 0:00:00 9.54 MB / s nbconvert-5.2. 100% | ###################################### | Time: 0:00:00 9.59 MB / s laptop-5.0.0 100% | ##################################### | Time: 0:00:00 8.24 MB / s

After execution, I ran the command

(tensor flow) C:> jupyter notebook

He opened a new Juipter window and was able to work normally -

import tensor flow as tf

+2
source

I managed to load the tensor stream in a Jupyter laptop on Windows: first do a conda, create a tensorflow installation, then activate tenorflow on the command line, and then run "Jupyter notebook" from the command line. Import Tensorflow into notepad without errors. However, I was not able to import "Pandas" & "Matplotlib, .... etc."

+1
source

I also had the same problem for a long time. I wanted to import the flow tensor into jupyter notepad in Windows 10. I followed all the instructions and commands that were offered and it did not work from the command line. Finally, I tried this command with Anaconda prompt and it worked successfully. If you are using a jupyter laptop in Anaconda, go to the Windows search terminal and enter “Anaconda Prompt” and enter the following command inside it: It will set the flow tensor inside the jupyter laptop.

 conda install -c conda-forge tensorflow 
+1
source

the problem can occur when the Jupyter laptop can start by default, but to be able to import the tenorflow and keras libraries, so you need to install the jupyter laptop, like what you installed the libraries

pip install jupyter

+1
source

There are two ways to fix this problem.

  1. The best way is to create a new virtual environment and install all the dependencies like jupyter notebook, tenorflow, etc.

conda install jupyter notebook

conda install -c conda-forge tensorflow

  1. Another way is to set the flow tensor in the current environment (base or any activated environment).

conda install -c conda-forge tensorflow

Note. It is recommended that you create a new virtual environment for each new project. Details of creating and managing a virtual environment using conda can be found here:

https://conda.io/docs/user-guide/tasks/manage-environments.html

0
source

The Conda environment extracts the tenorflow package from the core system packages of the site.

Step 1: just turn off the conda environment

 conda deactivate pip install tensorflow 

Step 2: Return to conda Wednesday

 conda activate YOUR_ENV_NAME jupyter notebook 

Step 3: Run the cell with import tensorflow you can import.

thanks

0
source

There is probably a problem with TensorFlow in your environment. In my case, after installing some libraries, my TensorFlow stopped working.

So I installed TensorFlow again using pip. like this:

just run

 pip install tensorflow 

then i imported it again in my jupyter notepad like:

 import tensorflow as ft 

If you want to install jupyter and base libs try this:

 pip install jupyter tensorflow keras numpy scipy ipython pandas matplotlib sympy nose 
0
source

All Articles