No module named tensorflow in jupyter

后端 未结 13 1240
梦如初夏
梦如初夏 2020-12-04 18:06

I have some imports in my jupyter notebook and among them is tensorflow:

ImportError                               Traceback (most recent call last)


        
相关标签:
13条回答
  • 2020-12-04 18:44

    run this command which will install tensorflow inside conda

    conda install -c conda-forge tensorflow
    
    0 讨论(0)
  • 2020-12-04 18:46

    Run python -m ipykernel install --user --name <Environment_Name>. This should add your environment to the jupyter kernel list.

    Change the kernel using Kernel->Change Kernel option or New-><Environment_Name>.

    Note : Replace <Environment_Name> with the actual name of the environment.

    0 讨论(0)
  • 2020-12-04 18:48

    I was able to load tensorflow in Jupyter notebook on Windows by: first do conda create tensorflow install, then activate tensorflow at the command prompt , then execute "Jupyter notebook" from command line. Tensorflow imports at the notebook with no error. However, I was unable to import "Pandas" &"Matplotlib, ....etc"

    0 讨论(0)
  • 2020-12-04 18:49

    This is what I did to fix this issue -

    I installed tensorflow for windows by using below link -

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

    Once done - I activated tensorflow by using below command -

    C:> activate tensorflow (tensorflow)C:> # Your prompt should change

    Once done I ran below command -

    (tensorflow)C:> conda install notebook

    Fetching package metadata ........... Solving package specifications: .

    Package plan for installation in environment

    The following NEW packages will be 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 notebook-5.0.0 100% |###############################| Time: 0:00:00 8.24 MB/s

    Once done I ran command

    (tensorflow)C:>jupyter notebook

    It opened new Juypter window and able to Run fine -

    import tensorflow as tf

    0 讨论(0)
  • 2020-12-04 18:51

    There are two ways to fix this issue.

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

    conda install jupyter notebook

    conda install -c conda-forge tensorflow

    1. The other way around is to install tensorflow in the current environment (base or any activated environment).

    conda install -c conda-forge tensorflow

    Note: It is advisable to create a new virtual environment for every new project. The details how to create and manage virtual environment using conda can be find here:

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

    0 讨论(0)
  • 2020-12-04 18:53

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

    jupyter kernelspec list

    which outputs the kernel information:

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

    Notice that the path points to the Jupyter kernel for the user. To use it within the the Anaconda environment, it needs to point to the conda env you are using, and look something like Anaconda3\envs\Env_Name\share\jupyter\kernels\python3.

    So, to remove the Jupyter kernelspec, just use:

    jupyter kernelspec remove python3

    or jupyter kernelspec remove python2 if you're using python 2

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

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

    0 讨论(0)
提交回复
热议问题