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

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

Posted by: admin April 3, 2018 Leave a comment

Questions:

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?

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

Questions:
Answers:

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

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

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

Usually installed location:
~/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

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

$ vi ~/.bashrc

add this line in the bottom of the basrc file.

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

check again in a new terminal

$ echo $TENSORFLOW

now you can 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 -m argument.