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

Question:

just installed tensorflow using pip with the command:

$ pip install tensorflow

On the “Getting Started” for Tensorflow they have an example for convolutional neural networks

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

Where is that directory located when installing with pip?

Asked By: eleijonmarck

||

Answers:

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

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

$ 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

$ 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 $TENSORFLOW you need to look in either

$ 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
Answered By: eleijonmarck

It depends on where is the $TENSORFLOW environment variable is set. Let’s help it setup.

First check, $ echo $TENSORFLOW if it returns blank, you need to setup the access of tensorflow in any directory from your console.

There are two cases of that:

  1. In case you have python from anaconda library/environment (let say you have anaconda2), the usually installed location is: ~/anaconda2/lib/python2.7/site-package/tensorflow

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

Now that you have identified the python version, use it as the onetime path in bash or profile. Type this Linux code:

$ vi ~/.bashrc

add this line at the bottom of the bashrc file.

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

check again in a new terminal

$ echo $TENSORFLOW to verify.

or use `source ~/.bashrc’ to reload the new environment variables.

Now you can all set to use

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

directly by

$ 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 the -m argument.

Answered By: Hemant K.
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.