Python 使用 pip、Mac OSX 安装 tensorflow 的文件夹在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33616732/
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:37:47  来源:igfitidea点击:

Where is the folder for Installing tensorflow with pip, Mac OSX?

pythonmacostensorflow

提问by eleijonmarck

just installed tensorflow using pip with the command:

刚刚使用 pip 和命令安装了 tensorflow:

$ pip install tensorflow

$ pip install tensorflow

On the "Getting Started" for Tensorflowthey have an example for convolutional neural networks

Tensorflow“入门”中,他们有一个卷积神经网络的例子

$ python tensorflow/models/image/mnist/convolutional.py

$ python tensorflow/models/image/mnist/convolutional.py

Where is that directory located when installing with pip?

使用 pip 安装时该目录位于何处?

采纳答案by eleijonmarck

Installing with pip, installs the packages to the directory "site-packages".

使用 pip 安装,将软件包安装到目录“site-packages”。

The following code shows the location of tensorflow as well as where pip installs the packages:

以下代码显示了 tensorflow 的位置以及 pip 安装包的位置:

$ pip show tensorflow

Which return:

哪个返回:

Metadata-Version: 2.0
Name: tensorflow
Version: 0.5.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.com/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: six, numpy

here Location:shows where the package is installed with

这里Location:显示了软件包的安装位置

$ cd /usr/local/lib/python2.7/site-packages/tensorflow


EDIT:

编辑:

As some people pointed out in the newer versions of tensorflow and depending on the $ echo $TENSORFLOWyou need to look in either

正如某些人在较新版本的 tensorflow 中指出的那样,根据$ echo $TENSORFLOW您需要查看

$ cd /usr/local/lib/python{2,3}.X/{site,dist}-packages/tensorflow

Or

或者

$ cd /usr/local/lib/python2.7/dist-packages/tensorflow/include/tensorflow/core/framework

回答by Hemant K.

It depends on where is $TENSORFLOW environment variable is set. Lets help it setup.

这取决于 $TENSORFLOW 环境变量的设置位置。让我们帮助它设置。

First check, $ echo $TENSORFLOWif it return blank, you need to setup to access from any directory from your console.

首先检查, $ echo $TENSORFLOW如果它返回空白,您需要设置从您的控制台从任何目录访问。

Case-1) In case you have python from anaconda library/environment (let say you have anaconda2)

案例1)如果你有来自anaconda库/环境的python(假设你有anaconda2)

Usually installed location: ~/anaconda2/lib/python2.7/site-package/tensorflow

通常安装位置:~/anaconda2/lib/python2.7/site-package/tensorflow

case-2.) In case of Python2.x or Python3.x, x = is subversion like 2.7 or 3.5 Usually installed location: /usr/local/lib/python2.x/site-packages/tensorflow

case-2.) 在 Python2.x 或 Python3.x 的情况下,x = 是像 2.7 或 3.5 这样的 subversion 通常安装位置: /usr/local/lib/python2.x/site-packages/tensorflow

Now you have identified python version. Use it as onetime path in bash or profile.

现在您已经确定了 python 版本。将其用作 bash 或配置文件中的一次性路径。

$ vi ~/.bashrc

$ vi ~/.bashrc

add this line in the bottom of the basrc file.

在 basrc 文件的底部添加这一行。

$ export $TENSORFLOW="~/anaconda2/lib/python2.7/site-packages/tensorflow:$PATH"

$ export $TENSORFLOW="~/anaconda2/lib/python2.7/site-packages/tensorflow:$PATH"

check again in a new terminal

在新终端中再次检查

$ echo $TENSORFLOW

$ echo $TENSORFLOW

now you can use

现在你可以使用

$ python tensorflow/models/image/mnist/convolutional.py

$ python tensorflow/models/image/mnist/convolutional.py

directly by

直接通过

$ python -m tensorflow.models.image.mnist.convolutional.py

$ python -m tensorflow.models.image.mnist.convolutional.py

Now your program as per description in TensorFlow tutorial will search these path with period (.) instead of "/" with -m argument.

现在,您的程序按照 TensorFlow 教程中的描述将使用句点 (.) 而不是带有 -m 参数的“/”搜索这些路径。