【问题标题】:ImportError: No module named 'tensorflow' in Spyder?ImportError:Spyder 中没有名为“tensorflow”的模块?
【发布时间】:2018-06-01 03:35:59
【问题描述】:

我在 mac osx yosemite 上,Spyder 给我这个错误:

ImportError: 没有名为“tensorflow”的模块

我在虚拟环境中运行 python3.5 以及 tensorflow 1.0.0

代码:

import numpy as np

import tensorflow as tf

import re

import time

追溯:

Python 3.5.4 |Anaconda, Inc.| (default, Oct  5 2017, 02:58:14)
Type "copyright", "credits" or "license" for more information.

IPython 6.1.0 -- An enhanced Interactive Python.
Traceback (most recent call last):

  File "<ipython-input-1-c6f06aebce6b>", line 1, in <module>
    runfile('/Users/connorwoodford/Desktop/Deep NLP A-Z/chatbot.py', wdir='/Users/connorwoodford/Desktop/Deep NLP A-Z')

  File "/Users/connorwoodford/anaconda3/envs/chatbot/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

  File "/Users/connorwoodford/anaconda3/envs/chatbot/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/Users/connorwoodford/Desktop/Deep NLP A-Z/chatbot.py", line 7, in <module>
    import tensorflow as tf

ImportError: No module named 'tensorflow'

【问题讨论】:

  • 您能提供您尝试执行的代码和整个回溯吗?
  • 请查看我在回答中提供的一些建议,并就它们是否有帮助提供一些反馈。

标签: python macos tensorflow spyder osx-yosemite


【解决方案1】:

打开一个终端 -

1. Run python
2. Run commands
    a.  import sys
    b. sys.executable
3. Copy and keep the output of the output from the last command somewhere
4. Open Spyder
    a. Go to Tools > Preferences > Python interpreter
    b. Select the option Use the following Python interpreter
    c. Paste the copied output of the command
5. Go to the consoles option in Spyder
    a. Choose Open Ipython console from options
    b. It might as for installing ipykernal, which you can do with
        i.  pip / conda install ipykernal cloudpickle
    c. Now you can use Keras, tensorflow without any error I believe.

它对我有用!

【讨论】:

    猜你喜欢
    • 2018-01-10
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    • 2020-09-07
    • 2020-02-23
    • 2017-07-03
    • 2021-11-23
    相关资源
    最近更新 更多