当我们在jupyter notebook中运行时可能会遇见没有某个包的情况,如下:

---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-24005895b065> in <module>
2 import h5py
3 import matplotlib.pyplot as plt
----> 4 import tensorflow as tf
5 from tensorflow.python.framework import ops
6 import tf_utils ModuleNotFoundError: No module named 'tensorflow'

首先我的jupyter notebook是在本地设置的python3的环境deeplearning下运行的:

userdeMacBook-Pro:~ user$ conda activate deeplearning
(deeplearning) userdeMacBook-Pro:~ user$ jupyter notebook

但是很奇怪的是我python3的环境下已经安装好了tensorflow,但是jupyter中还是显示没有

(deeplearning) userdeMBP:~ user$ python
Python 3.7.2 (default, Dec 29 2018, 00:00:04)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> tensorflow.__version__
'1.13.1'
>>>

可见安装了1.13.1版本的tensorflow

解决方法有:

打开你的anaconda navigator,按下图选择,之后apply安装就行:

报了个错:

UnsatisfiableError: The following specifications were found to be in conflic
pytorch
tensorflow == 1.11.
use conda info <package> to check dependencies

使用conda info tensorflow查看依赖后,发现tensorflow <= 1.12.0版本不支持python3.7,而anaconda navigator中提供的tensorflow的最高版本是1.12.0,所以我就将其降到了3.6版本,即在指定的环境deeplearning下运行:

(deeplearning) userdeMBP:~ user$ conda install python=3.6

当然这样可能会导致一些之前安装的包的丢失,因为再import tensorflow时可见之前安装的tensorflow没了:

(deeplearning) userdeMBP:~ user$ python
Python 3.6. |Anaconda, Inc.| (default, Dec , ::)
[GCC 4.2. Compatible Clang 4.0. (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line , in <module>
ModuleNotFoundError: No module named 'tensorflow'

然后再安装就可以看见安装成功:

然后再查看:

(deeplearning) userdeMBP:~ user$ python
Python 3.6. |Anaconda, Inc.| (default, Dec , ::)
[GCC 4.2. Compatible Clang 4.0. (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> tensorflow.__version__
'1.12.0'
>>>

可见相应的环境deeplearning中成功安装了tensorflow == 1.12.0版本

⚠️

如果在过程中还是有UnsatisfiableError的错,除了依赖的问题,还可以试试:

userdeMBP:~ user$ conda update conda

更新conda

jupyter notebook中No module named 'tensorflow'的更多相关文章

  1. Python 在cmd中import模块成功,但是在jupyter notebook中No module xxx found

    由于需要用到python中的某个库,因此打开命令行窗口cmd,然后使用pip安装.安装成功后,在cmd中输入python调出python环境,import该模块并使用,可以正常使用.但是打开juypt ...

  2. 在jupyter notebook导入tensorflow出错:No module named tensorflow 解决办法

    1.背景 首先说一下我的环境: os : windows10 anaconda版本:2.7 官网提供了两种方法来安装TensorFlow:pip和anaconda.我使用的是anaconda方法.按照 ...

  3. 解决不能再jupyter notebook中使用tensorflow

    在搭建cuda + Anaconda + tensorflow的开发环境时,在虚拟环境中的jupyter notebook启动后无法导入tensorflow.具体解决方案如下: 1.首先在虚拟环境中安 ...

  4. 关于win系统下Anaconda与TensorFlow的安装相关事宜以及错误:ImportError: No module named 'tensorflow'的解决

    1.安装TensorFlow之前应该先安装Anaconda,不需要安装python,否则会出问题,我安装的版本是Anaconda3-4.2.0-Windows-x86_64,在这个链接上可以找到--h ...

  5. Anaconda3 tensorflow安装 及ModuleNotFoundError: No module named 'tensorflow' 解答

    Anaconda3 的安装,参考:手把手教你如何安装Tensorflow(Windows和Linux两种版本) tensorflow的安装,参考:深度学习(TensorFlow)环境搭建:(三)Ubu ...

  6. jupyter notebook中出现ValueError: signal only works in main thread 报错 即 长时间in[*] 解决办法

    我在jupyter notebook中新建了一个基于py3.6的kernel用来进行tensorflow学习 但是在jupyter notebook中建立该kernel时,右上角总是显示 服务正在启动 ...

  7. Jupyter notebook中的.ipynb文件转换成python的.py文件

    转自:https://blog.csdn.net/wyr_rise/article/details/82656555 Jupyter notebook中.py与.ipynb文件的import问题   ...

  8. 在jupyter notebook中同时安装python2和python3

    之前讨论过在anaconda下安装多个python版本,本期来讨论下,jupyter notebook中怎样同时安装python2.7 和python3.x. 由于我之前使用的jupyter note ...

  9. 解决在jupyter notebook中遇到的ImportError: matplotlib is required for plotting问题

    昨天学习pandas和matplotlib的过程中, 在jupyter notebook遇到ImportError: matplotlib is required for plotting错误, 以下 ...

随机推荐

  1. Swap file ".BranchModel.class.php.swp" already exists!

    在 Linux 下的 vim 编辑过程中,由于某种原因异常退出正在编辑的文件,再次编辑该文件时,会出现如下提示: 1.解决方法:直接 ll -a -a 列出目录下的所有文件,包括以 . 开头的隐含文件 ...

  2. PHP Warning: PHP Startup: redis: Unable to initialize module Windows版本phpredis扩展

    版权声明:经验之谈,不知能否换包辣条,另,转载请注明出处.https://www.cnblogs.com/zmdComeOn/category/1295248.html [root@VM_0_2_ce ...

  3. nodeJs express mongodb 建站(mac 版)

    基本环境 homebrew.node.npm.express.mongodb 1.node .npm : (1)辅助工具:homebrew安装(mac下一个软件管理工具,相当于Red hat的yum, ...

  4. Human Motion Analysis with Wearable Inertial Sensors——阅读2

    Human Motion Analysis with Wearable Inertial Sensors 实时人体运动跟踪已经应用于生物医学领域的许多应用:临床步态分析,运动康复,跌倒检测,关节生物力 ...

  5. 进入root提示Authentication failure错误

    新安装Ubuntu 18.4,想进入root角色,提示“Authentication failure” 失败. 因为是新安装,并无root的密码,所以需要新增加: sudo passwd root,之 ...

  6. 原型模式ProtoType

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/3/4 21:49 # @Author : ChenAdong # @emai ...

  7. A problem has been detected and windows has been shut down to prevent damage to your computer.他么啥意思?看这里!【蓝屏】

    A problem has been detected and windows has been shut down to prevent damage to your computer.  检测到问 ...

  8. Table 'performance_schema.session_variables' doesn't exist错误的一

    mysql驱动 jar 换到现在最新的mysql-connector-java-5.1.39-bin.jar

  9. mssql sqlserver 使用sql脚本获取群组后,按时间排序(asc)第一条数据的方法分享

    摘要: 下文讲述使用sql脚本,获取群组后记录的第一条数据业务场景说明: 学校教务处要求统计: 每次作业,最早提交的学生名单下文通过举例的方式,记录此次脚本编写方法,方便以后备查,如下所示: 实现思路 ...

  10. 【MM系列】SAP里批量设置采购信息记录删除标记

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP里批量设置采购信息记录删除标记 ...