How to visualize dask graphs? - python-2.7

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

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?

Is it possible to use python 2.7 with julia while anaconda is preinstalled with python 3.4?

I installed julia and am using some nice python packages like matplotlib in julia using PyCall. I have installed all python stuff with anaconda and used python 3.4. I am able to switch from enviroment in anaconda to use python 2.7.
The thing is that I would like to import openCV as a python package in julia but it only runs with python 2.7. So I was wondering if it was possible to use python 2.7 in julia trough anaconda while python 3.4 was in anaconda's main install.
A working option would be to reinstall anaconda with version 2.7, but I don't want that.
Thanks in advance,
Frank
Current Anaconda installation
OpenCV3 on Python3
The thing is that I would like to import openCV as a python package in julia but it only runs with python 2.7.
Have you tried installing OpenCV3 with your Anaconda Python version 3.x installation?
conda install -c https://conda.anaconda.org/menpo opencv3
Add another Python 2.7 environment
You could also create new Anaconda Python environment with Python 2.7 installed using your current Anaconda install with conda create:
conda create -n py27 python=2.7 anaconda
Assuming you are using the full Anaconda distribution, I understand this will install a full Anaconda Python 2.7 environment (see miniconda, below), but it will not mess up your previous Anaconda Python 3 env.
http://conda.pydata.org/docs/py2or3.html#install-a-different-version-of-python
Conda.jl Julia package
You could use Conda.jl for managing Julia binary dependencies:
This package allows one to use conda as a binary provider for Julia. While other binary providers like Hombrew.jl, AptGet.jl or WinRPM.jl are platform-specific, Conda.jl is a cross-platform alternative. It can also be used without administrator rights, in contrast to the current Linux-based providers.
conda is a package manager which started as the binary package manager for the Anaconda Python distribution, but it also provides arbitrary packages. Instead of the full Anaconda distribution, Conda.jl uses the miniconda Python environment, which only includes conda and its dependencies.
You can install it by running Pkg.add("Conda") at the Julia prompt.
Install and load Conda.jl:
julia> # Pkg.add("Conda")
julia> using Conda
Search for the package:
julia> Conda.search("opencv")
1-element Array{AbstractString,1}:
"opencv"
Install the package:
julia> Conda.add("opencv")
Fetching package metadata: ....
Solving package specifications: ....................
Package plan for installation in environment /home/ismaelvc/.julia/v0.4/Conda/deps/usr:
The following packages will be downloaded:
package | build
---------------------------|-----------------
jpeg-8d | 0 699 KB
wheel-0.29.0 | py27_0 81 KB
opencv-2.4.10 | np110py27_1 9.2 MB
------------------------------------------------------------
Total: 10.0 MB
The following NEW packages will be INSTALLED:
jpeg: 8d-0
opencv: 2.4.10-np110py27_1
The following packages will be UPDATED:
wheel: 0.26.0-py27_1 --> 0.29.0-py27_0
Fetching packages ...
jpeg-8d-0.tar. 100% |##########| Time: 0:00:01 652.02 kB/s
wheel-0.29.0-p 100% |##########| Time: 0:00:00 336.94 kB/s
opencv-2.4.10- 100% |##########| Time: 0:00:10 962.48 kB/s
Extracting packages ...
[ COMPLETE ]|##########| 100%
Unlinking packages ...
[ COMPLETE ]|##########| 100%
Linking packages ...
[ COMPLETE ]|##########| 100%
Total: 10.0 MB
Check that it worked:
shell> .julia/v0.4/Conda/deps/usr/bin/python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
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 cv2
>>> cv2.__version__
'2.4.10'
>>>
Within Julia via PyCall:
julia> using PyCall # Pkg.add("PyCall")
julia> #pyimport cv2
julia> #pyimport sys
julia> sys.version |> println
2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
julia> import Conda
julia> Conda.PYTHONDIR
"/home/ismaelvc/.julia/v0.4/Conda/deps/usr/bin"
Specify the python version for PyCall
https://github.com/stevengj/PyCall.jl#specifying-the-python-version
Miniconda
Or use miniconda for Python 2.7 directly:
http://conda.pydata.org/miniconda.html
Conda.jl installs by default the Python version 2.7.x miniconda (installing everything in ~/.julia/v0.x/Conda).
In Linux:
It is often very easy to install only the things you want, without having to use Anaconda (I'm assuming you use Mac or PC, but still useful to others), example uses ArchLinux package manager pacman, it's similar with other Linux distributions package managers like: yum, zipper, apt-get, etc:
shell> sudo pacman -S opencv
warning: opencv-2.4.12.2-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Package (1) Old Version New Version Net Change Download Size
extra/opencv 2.4.12.2-2 2.4.12.2-2 0.00 MiB 7.10 MiB
Total Download Size: 7.10 MiB
Total Installed Size: 38.86 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n] n
shell> python2
Python 2.7.11 (default, Dec 6 2015, 15:43:46)
[GCC 5.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.12.2'
>>>

TensorFlow no attribute 'make_template'

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.

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.

Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

I'm really new to Python and Django.... What I'm trying to do is:
Install Python 2.7 on Mac OS 10.6.8
Install pip Install Django
Install virtualenvwrapper
Create virtual environment
Install Django-Cms
I think, I'll be is ok from Install virtualenvwrapper to the Django-Cms installation because I have already done it, but in the first steps I got some troubles.
I download Python 2.z from python.org the Python 2.7.3 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and later [2]), installed whit the wizard . That create a directory /System/Library/Frameworks/Python.framework/Versions with inside my 2.7 folder.
My directory /System/Library/Python is empty
I'm sure I've Python installed cos:
python --version
Python 2.7.3
but when I try easy_install pip it gave me:
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/bin/easy_install-2.6", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 16, in <module>
import sys, os, zipimport, time, re, imp, new
ImportError: No module named os**
Now no idea of what does mean ...so if somebody could help out from this and put me on the direction where I can istall my virtualenvwrapper I can take it from there.
I'm Junior a front end developer never touch back end so pls be specific and explain me what I need to do as u speak with a child.
You seem to have things turned around. Virtualenv creates a python environment that encapsulates a python install. So you want to do the following:
Install python
Create a virtualenv using that version of python (eg. virtualenv --python="path to python in 1" virt)
Switch to that virtualenv (workon virt)
Now install Django, etc. inside of the virtualenv virt
Here is the recipe I used to get my environment setup and running.
Are you using homebrew? I've found that's the most reliable way to get stuff on the mac.