Install pip and Virtualenv:
$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv
Create a Virtualenv environment in the directory ~/tensorflow:
$ virtualenv --system-site-packages ~/tensorflow
Activate the environment:
$ source ~/tensorflow/bin/activate # If using bash
$ source ~/tensorflow/bin/activate.csh # If using csh
(tensorflow)$ # Your prompt should change
Now, install TensorFlow just as you would for a regular Pip installation. First select the correct binary to install:
# Mac OS X, GPU enabled, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.0-py2-none-any.whl
Finally install TensorFlow:
(tensorflow)$ pip install --upgrade $TF_BINARY_URL
When you are done using TensorFlow, deactivate the environment.
(tensorflow)$ deactivate
$ # Your prompt should change back
To use TensorFlow later you will have to activate the Virtualenv environment again:
$ source ~/tensorflow/bin/activate # If using bash.
$ source ~/tensorflow/bin/activate.csh # If using csh.
(tensorflow)$ # Your prompt should change.
# Run Python programs that use TensorFlow
....
# When you are done using TensorFlow, deactivate the environment.
(tensorflow)$ deactivate