使用 Tensorflow 作为 Anaconda 的环境
Using Tensorflow as environment of Anaconda
我已经安装了 anaconda (python3.6) 并按照此处所述安装了 tensorflow:
conda create -n tensorflow python=3.5
并激活了 tensorflow,现在我想 运行 sublime text3 中的示例代码
我无法导入张量流。我在 Spyder 中尝试过相同的结果。
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
知道我在这里做错了什么吗?
(代码绝对正确)
您在这里所做的是创建一个名为 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"
}
我已经安装了 anaconda (python3.6) 并按照此处所述安装了 tensorflow:
conda create -n tensorflow python=3.5
并激活了 tensorflow,现在我想 运行 sublime text3 中的示例代码 我无法导入张量流。我在 Spyder 中尝试过相同的结果。
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
知道我在这里做错了什么吗? (代码绝对正确)
您在这里所做的是创建一个名为 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"
}