4

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'

1 Answers1

2

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!

Lord Elrond
  • 13,430
  • 7
  • 40
  • 80
Hevlastka
  • 1,878
  • 2
  • 18
  • 29
  • I wanted to get it work with default pip and python2.7 installation at first hand. As @Hevlatska recommended, python3 and pip3 installation solves the issue. – Şükrü Ozan Ph.D. Dec 18 '15 at 12:56
  • 1
    @ŞükrüOzan if you're happy with the solution would you mind accepting it as a valid answer? :) – Hevlastka Dec 21 '15 at 14:42