Issue
I just installed TensorFlow under VirtualEnv on Mac OSX El Capitan. Now I am trying to understand the structure by following examples given in tensorflow.org website.
I am new to python and its syntax. But as far as I can figure out the attribute called getsitepackages() is kind of important in order to list modules' attributes easily. But with its default python and virtualenv version on el capitan, it seems that virtualenv can not inherit getsitepackages()
attribute of the module called "site".
Hence I couldn't run the simple example command (python -c 'import site; print("\n".join(site.getsitepackages()))'
) to locate tensorflow libraries.
I guess this is a known bug but I couldn't find a way to solve this issue. I just wonder if anyone has already came up with and solved this problem?
P.S. Outside the virtualenv getsitepackages()
just works fine. But in the virtualenv I get the following error
python -c 'import site; print("\n".join(site.getsitepackages()))'
Traceback (most recent call last):
File "< string >", line 1, in < module >
AttributeError: 'module' object has no attribute 'getsitepackages'
Solution
This seems to be a problem with sites.py
which dates all the way back to 2012. As mentioned here.
Have a stab at trying to create the virtualenv using a different python version. For example:
virtualenv -p python3 virtualenvname
It's worth checking what python version you're running (python --version
). This seems to only be a problem with python2.7
- earlier versions like python2.6
do not experience this problem however they lack a lot of useful packages that were added in python2.7
.
My recommendation would be to run it under python3
or python3.4
.
TensorFlow seems to support python3
with the 0.6.0 release.
Hope this helps!
Answered By - Hevlastka Answer Checked By - Dawn Plyler (WPSolving Volunteer)