【问题标题】:Using Tensorflow as environment of Anaconda使用 Tensorflow 作为 Anaconda 的环境
【发布时间】:2017-08-28 10:44:33
【问题描述】:

我已经安装了 anaconda (python3.6) 并安装了 tensorflow,如下所述:

conda create -n tensorflow python=3.5

并激活 tensorflow,现在我想在 sublime text3 中运行示例代码 而且我无法导入张量流。我在 Spyder 中尝试过相同的结果,结果相同。

 import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

知道我在这里做错了什么吗? (代码绝对正确)

【问题讨论】:

    标签: python python-3.x tensorflow anaconda importerror


    【解决方案1】:

    您在这里所做的是创建一个名为 tensorflow 的虚拟环境。

    正确的做法是:(顺序相同)

    $ conda create --name yourenv python=3.5 anaconda
    $ source activate yourenv
    $ conda install -n yourenv tensorflow
    

    然后,从ipython 终端执行:

    import tensorflow as tf
    

    要在 SublimeText 编辑器中工作,请按照此处记录的步骤操作:sublimeText and VirtualEnv

    基本上,你需要在项目设置中添加以下行。

    "settings": {
        "python_interpreter": "/home/user/.virtualenvs/example/bin/python"
    }
    

    对于使用 Anaconda 发行版的人来说,情况略有不同。

    "settings": {
            "python_interpreter": "/home/user/anaconda3/envs/myenv/bin/python"
        }
    

    【讨论】:

    • 我已经设法在 spyder 中使用了,但在 sublime text 中运行它仍然有问题
    猜你喜欢
    • 1970-01-01
    • 2018-06-20
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多