TensorFlow no attribute 'make_template' - python-2.7

I am trying to get familiar with tensorflow and NNs. I recently crashed into this problem when I tried to use tensorflow.make_template(). I first noticed that there were no auto-complete option in the IDE I use, and then I just tried to call the function from the python cmd:
$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.make_template()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'make_template'
>>>
I installed tensorflow from sources, and the protobuf version installed is:
$ git submodule status
55ad57a235c009d0414aed1781072adda0c89137 google/protobuf (v3.0.0-alpha-4-179-g55ad57a)
I haven't faced any similar behaviour with other tensorflow functions so far.
Any ideas about what's the issue causing this one?

As noted in the comments, this issue was due to a mismatch between the installed version of TensorFlow (0.5.0) and the downloaded source (0.6.0).
To upgrade to the latest development version of TensorFlow, follow the instructions to install from source, then build and install the PIP package based on that source.

Related

Import error -- Python looking in wrong $PATH order

I'm trying to switch from Homebrew Python to Anaconda Python.
My $PATH is:
234:~ user$ echo $PATH
/Users/user/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
Also, when I check which python, which pip, and which conda I get the anaconda directory for all three. But I still get the following when I try to import some standard package (which is installed in the anaconda directory):
234:~ user$ python
Python 2.7.13 |Anaconda custom (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
'>>> import numpy
Traceback (most recent call last):
File "<'stdin>", line 1, in
File "/usr/local/lib/python2.7/site-packages/numpy/init.py", line 142, in <'module> ...
ImportError:
Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). Otherwise reinstall numpy.
I have tried a reboot and completely uninstalling anaconda and reinstalling, all to no avail. Why is python still using my usr/local/lib directory to hunt for packages? How do I redirect it to the anaconda directory?

How to visualize dask graphs?

I am following the official docs, however, getting the error during import.
F:\>python
Python 2.7.11 |Anaconda custom (64-bit)| (default, Feb 16 2016, 09:58:36)[MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from dask.dot import dot_graph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\dask\dot.py", line 11, in <module>
graphviz = import_required("graphviz", "Drawing dask graphs requires the "
File "C:\Anaconda\lib\site-packages\dask\utils.py", line 70, in import_required
raise RuntimeError(error_msg)
RuntimeError: Drawing dask graphs requires the `graphviz` python library and the `graphviz` system library to be installed.
>>>
I am running Anaconda and have installed graphviz.
C:\>conda install graphviz
Using Anaconda API: https://api.anaconda.org
Fetching package metadata .........
Solving package specifications: ..........
# All requested packages already installed.
# packages in environment at C:\Anaconda:
#
graphviz 2.38.0 2
I've got a directory C:\Anaconda\Library\bin\graphviz with the bunch of .exe, .dll and other files inside. There is also something in PATH variable:
F:\>where dot
C:\Anaconda\Library\bin\dot.bat
Here is the content of that file (C:\Anaconda\Library\bin\dot.bat):
#echo off
%~dp0.\graphviz\dot.exe %*
I have dask 0.11.0 installed:
F:\>conda list dask
# packages in environment at C:\Anaconda:
#
Using Anaconda API: https://api.anaconda.org
dask 0.11.0 py27_0
These errors appear both in Windows and in Linux (Ubuntu 16.04 with all recent updates).
What else does it require?
I'm not using Anaconda, but generaly if you wish to use graphviz you should:
Install the graphviz python module (probably with pip install graphviz).
Download and install the graphviz software.
To use the visualizing part of dask in anaconda, install both the graphviz and python-graphviz packages. Dask depends on a python interface to graphviz to do visualizations.
$ conda install graphviz python-graphviz

Python Sass unable to load DLL

On Windows, Python 3.4 64bit.
Installed libsass, but unable to run it.
Probably something to do with the 32bit vs 64bit.
pip install libsass
Requirement already satisfied (use --upgrade to upgrade): libsass in c:\python34\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): six in c:\python34\lib\site-packages (from libsass)
python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import sass
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\site-packages\sass.py", line 24, in
from _sass import OUTPUT_STYLES, compile_filename, compile_string
ImportError: DLL load failed: %1 is not a valid Win32 application.
Help!
You should just install the appropriate wheel from: https://pypi.python.org/pypi/libsass (libsass-0.8.3-cp34-none-win_amd64.whl)
I just experienced a similar error:
File "K:\Python27\lib\site-packages\sass.py", line 26, in <module>
from _sass import OUTPUT_STYLES, compile_filename, compile_string
ImportError: DLL load failed: The specified module could not be found.
After a bunch of searching, it looked like on Windows I was missing the needed C++, and again, being Windows, the simplest way to fix this was to update VisualStudio with the C++ library.
Error is gone and libsass is working great after doing this.
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit(Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import sass
>>> print sass.compile(string='a { b{ color: blue; } }')
a b { color: blue; }
I know it doesn't directly answer the question, but thought I'd leave the solution I found here, for those who are in the process of losing a couple hours like I did.
I had Visual Studio 2013 - installed Visual Studio Community 2015 (making sure to select the C & C++ libraries)
The libsass DLL ("_sass.pyd" in the python world) probably misses some of its dependencies.
You can just install the small "Visual C++ Redistributable for Visual Studio 2015" to get that bunch of missing C++ components.

PIP not working in Pythonxy?

I am using Pythonxy (have uninstalled all old instances of Python) and it has pip as a standard plugin as per the document page https://code.google.com/p/pythonxy/wiki/StandardPlugins
But when i use pip commands it fails. Can anybody kindly please figure out the mistake I am making?
P.S. Pip used to work well under Python before I moved to Pythonxy
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Imported NumPy 1.8.0, SciPy 0.13.3, Matplotlib 1.3.1
+ guidata 1.6.1, guiqwt 2.3.1
Type "scientific" for more details.
>>> pip freeze
File "<stdin>", line 1
pip freeze
^
SyntaxError: invalid syntax
>>> pip install numpy
File "<stdin>", line 1
pip install numpy
^
SyntaxError: invalid syntax
>>>
PIP has never worked that way.
Use a command line i.e. BASH and not Python Interpreter.
Sure that
pip install numpy
is invalid Python statement. You can use mentioned command from your shell.

Can't find django-admin.py in Lubuntu 12.10

I just installed Lubuntu 12.10 on a new laptop, and I'm trying to get Django working. I installed it from Synaptic Package Manager, and when I try to make a sample project on the command line, this is what I get:
amanda#amanda-ThinkPad-E420:~$ django-admin.py startproject caltrain
django-admin.py: command not found
And I verified Django is installed correctly,
amanda#amanda-ThinkPad-E420:~$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.4.1
>>>
Is this some sorta path issue or something? I don't remember having this issue on my Mac, but again I'm not very Unix savvy to begin with.
This information may be a bit stale, but I found this information that seems similar to your problem: http://ubuntuforums.org/showthread.php?t=1267372
With this solution:
Name of "django-admin.py" was changed to "django-admin" in /usr/bin directory in the python-django package.
To get around this I just created a symbolic link to django-admin named django-admin.py.
ln -s /usr/bin/django-admin /usr/bin/django-admin.py (as root)
Hope this helps, but again this was written in 2009.
You should see this. it contains details concerning problems with django-admin.py location
https://docs.djangoproject.com/en/1.6/faq/troubleshooting/#troubleshooting-django-admin-py