Anaconda:当使用pip安装时,Tensorflow将安装到.local

时间:2017-03-05 04:29:59

标签: tensorflow pip anaconda

每当我在Anaconda环境中使用pip安装Tensorflow时,它似乎都会保存到$/HOME/.local/目录,而不是相应的anaconda2/env/目录。例如

$ source activate foo  # No TensorFlow Installed
(foo) $ pip3 install tensorflow-gpu
(foo) $ python
>>> import tensorflow as tf
>>> tf.__file__
$HOME/.local/lib/python3.5/site-packages/tensorflow/__init__.py'

我希望最后一行能说出类似的话 $HOME/anaconda2/envs/foo/lib/python3.5/site-packages/tensorflow/__init__.py 而不是指向一些绝对目录。

1 个答案:

答案 0 :(得分:1)

虽然不是100%满意,但我的工作(基于此git issue thread)是为了确保在使用pip安装tensorflow之前将环境变量PYTHONNOUSERSITE设置为True。所以,新代码是:

$ export PYTHONNOUSERSITE=True   # <--- DO THIS FIRST
$ source activate foo
(foo) $ pip3 install tensorflow-gpu
(foo) $ python
>>> import tensorflow as tf
>>> tf.__file__
$HOME/anaconda2/envs/foo/lib/python3.5/site-packages/tensorflow/__init__.py