Python Ubuntu 上的 Tensorflow 和 Anaconda?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33646541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:41:27  来源:igfitidea点击:

Tensorflow and Anaconda on Ubuntu?

pythonanacondatensorflow

提问by Arabasta

On my Ubuntu 14.04, I have installed tensorflow, using "pip", as specified in the Tensorflow Installation instructionsand I made sure it was working by importing it in python and it did work.

在我的 Ubuntu 14.04 上,我已经按照Tensorflow 安装说明中的说明使用“pip”安装了 tensorflow,并且我通过在 python 中导入它来确保它正常工作并且它确实有效。

Then, I installed Anaconda and it changed my .bashrc file by adding the following line to it:

然后,我安装了 Anaconda,它通过向其中添加以下行来更改我的 .bashrc 文件:

export PATH="/home/sonny/anaconda2/bin:$PATH"

But because of this change, now it looks into the PATH above, which doesn't contain tensorflow. now I can't import tensorflow in my python code.

但是由于这个变化,现在它查看上面的 PATH,它不包含 tensorflow。现在我无法在我的 python 代码中导入 tensorflow。

What is the proper way to extend the $PATH environment variable so that it stays using everything from anaconda2 but it becomes able to import "tensorflow"?

扩展 $PATH 环境变量以使其继续使用 anaconda2 中的所有内容但能够导入“tensorflow”的正确方法是什么?

采纳答案by Arabasta

I solved the problem but in a different way! I found a link where the tensorflow.whl files were converted to conda packages, so I went ahead and installed it using the command:

我以不同的方式解决了这个问题!我找到了一个链接,其中 tensorflow.whl 文件被转换为 conda 包,所以我继续使用以下命令安装它:

conda install -c https://conda.anaconda.org/jjhelmus tensorflow

and it worked, since the $PATH points to anaconda packages, I can import it now!

它起作用了,因为 $PATH 指向 anaconda 包,我现在可以导入它!

Source is here

来源在这里

回答by gauss256

I had the same problem and decided it was easiest to start over, install Anaconda first and then TensorFlow after that.

我遇到了同样的问题,并认为最容易重新开始,先安装 Anaconda,然后再安装 TensorFlow。

回答by Freek Wiekmeijer

I suspect that pip is giving you a TensorFlow installation in cpython, not anaconda.

我怀疑 pip 在 cpython 中给你一个 TensorFlow 安装,而不是 anaconda。

How about a virtualenv?

虚拟环境怎么样?

# Create env
$ virtualenv --python=/path/to/anaconda /path/to/your/env

# Activate env
$ source /path/to/your/env/bin/activate

# Install Tensorflow
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

回答by gkhnavarro

I solved the problem using this:

我用这个解决了这个问题:

conda create --name=tensorenv python=3.4
source activate tensorenv

回答by yxtay

Since v0.10.0, tensorflowis a community maintained conda package in the conda-forgechannel. Hence, it can be installed directly with the following command:

从 v0.10.0 开始,tensorflow是一个社区维护的conda-forge频道中的conda包。因此,它可以使用以下命令直接安装:

conda install -c conda-forge tensorflow

The instructions on the TensorFlow documentationhas also been updated.

信中的指示TensorFlow文档也已更新。

To facilitate future updates, it is probably a good idea to add conda-forgechannel into your conda config:

为了便于将来的更新,将conda-forge频道添加到您的 conda 配置中可能是个好主意:

conda config --add channels conda-forge

In fact, tensorflow=0.10.0rc0was recently added onto the Anaconda default channeland will be installed instead if the conda-forgechannel is not specified:

事实上,tensorflow=0.10.0rc0最近已添加到Anaconda 默认频道中,如果conda-forge未指定频道,则会安装:

conda install tensorflow

回答by Sai Harsha

Install tensorflow from the following command. Conda will take care of the installation process.

从以下命令安装 tensorflow。Conda 将负责安装过程。

conda install -c conda-forge tensorflow

conda install -c conda-forge tensorflow

回答by Qibiron Who

Actually, the TensorFlow Official website made every detail of installing. The Operation System Windows, Mac OS, Ubuntu; the environment with GPUor just CPU, every single detail of problems you may come up with.

其实安装的每一个细节,TensorFlow官网都做了。操作系统Windows、Mac OS、Ubuntu;使用GPU或仅使用CPU的环境,您可能会想到的问题的每一个细节。

Check this out

看一下这个

Installing TensorFlow on Ubuntu with Anaconda

使用 Anaconda 在 Ubuntu 上安装 TensorFlow

you will not regret.

你不会后悔的。

Once you visit that you may also find like

一旦你访问,你可能还会发现像

Installing TensorFlow on Windows with Anaconda

使用 Anaconda 在 Windows 上安装 TensorFlow