How do I place dot on system path (graphviz related)? - graphviz

I'm running graphviz per an online tutorial, but ran into an error: ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH
Tried reinstalling on anaconda onto PATH environment. Doesn't work. Is any kind soul able to guide amateur here? Much appreciated. Thanks.
Code used
from sklearn import tree
import graphviz
tree_graph = tree.export_graphviz(tree_model, out_file=None, feature_names=feature_names)
graphviz.Source(tree_graph)

Related

Issue with plot model in Keras

I have installed all the needed packages, but looks like plot_model still doe not work. I get the following error:
You must install pydot (`pip install pydot`) and install graphviz (see instructions at https://graphviz.gitlab.io/download/) for plot_model/model_to_dot to work.
But I have isntalled them both. Any idea how to go around this issue?

Tutorial for installing numpy with OpenBLAS on Windows

Please, I do need a light here. I want to install numpy using a good BLAS/LAPACK lib on Windows, but absolutely no page explains the process well enough. It seems OpenBLAS is a good and fast option.
The goal is to use "theano" with "keras", and "theano" requires that the libraries be "dynamic", not static. (Not sure I understand what that means, but it causes slowness and memory issues)
Please treat me as a complete newbie. Give me a step by step tutorial on how to do it! Don't forget to tell me "where" files should go! Which folders should go in PATH! What commands exactly I should call, and what are their output, where? What do I do with their results or with compiled files? How does numpy find them? Etc. All the sites I've seen seem to think I'm a linux expert and already know everything.
What I have tried:
Downloaded the compiled version of numpy+mkl from here -- This does install numpy, it becomes usable, but theano presents the memory leak problem, besides working slowly. Is it a matter of setting the right ldflags in the .theanorc file? If so, which are the flags? - About the MKL libraries, this answer may be useful?
Tried installing Anaconda - it doesn't work either, and I had no idea about what went wrong. It gave me messages suggesting installing some extra stuff, it worked but incredibly slow. More than 10 times slower than my bugged numpy version mentioned above (so, unacceptable, impossible to work at that speed). If I have to go changing everything about Anaconda, it's better to use a regular python instead and know what is going on.
Found these already compiled BLAS/LAPACK libraries (.dll and .lib) files. But.... what am I supposed to do with them? -- Simply adding their folders to the PATH var and installing numpy gives me "numpy-atlas", not the libraries I downloaded. How do I make numpy see them?
Tried to understand this page, but yet, it seems it will lead me exactly to the previous case, what will I do with the results? Where are the libs they suggest I use? What are the suggested quickbuild scripts, where are they?
Found the Cygwin option here. I haven't tried it, but it sounds it should be something easier than reinstalling all my python and packages, all from Cygwin
Year 2021: this works with miniconda on Windows 10
conda create -n openblas python=3.8
conda activate openblas
conda install conda-forge::blas=*=openblas
conda install -c conda-forge numpy
Tested also with matplotlib-base.
Tried following the building instructions in http://scipy.github.io/devdocs/building/windows.html a number of times without success.
[MY SOLUTION]
After extensive reading of the logs and related forums, came up with a method that has worked for me in two windows machines already. Posted a batch file with the steps I used in https://github.com/jhvital/build-scipy-openblas.
The show_config method shows linkage to openblas libraries, and this was confirmed by comparing the runtimes of scripts against the scipy installed with conda install scipy, which installs the mkl package.
Still I'm not entirely sure whether the libraries were linked correctly. Feedback would be appreciated.
The build instructions for SciPy is tested a number of times and it seems to be working.
You can find the instructions here http://scipy.github.io/devdocs/building/windows.html
Note that this is still a very delicate procedure and needs to be done very carefully. It still does not guarantee success thanks to Windows being Windows. However please take the time to report any issues should you encounter any at https://github.com/scipy/scipy.org/issues (notice it is not the scipy repo but but scipy.org repo)
I am not sure what's the error you have recieved when trying to get openblas & numpy using anaconda.
For openblas on windows using anaconda3 python 3.6v this works:
conda install -c menpo openblas
ref: https://anaconda.org/menpo/openblas
For numpy:
it is :conda install numpy. if you are looking for a specific version of numpy use: conda install numpy=version_number

Theano is missing modules

I am on windows 64bit, I have installed anaconda, and managed to create an environment with python 2.7
I have numpy, pylearn2, theano, and every package is built properly
I have been able to import all these modules, however I get some very esoteric messages when I try to complete the model, like
ImportError: Could not import pylearn2.models.softmax_regression but could import pylearn2.models. Original exception: No module named dnn
Then I tried to actually find the package in the installation, but inside the cuda folder, there is no module named dnn. Looking at github, I see that it should be there.
Why is theano missing modules? I installed using conda install theano, and it gave some suggestions, I have managed to pick the correct one.
I have uninstalled and installed theano many time, I can import it but I can never get the proper modules.
What is going wrong?
Ok, after a few days of search, it seems like Theano installed from anaconda is missing a lot of modules. However, installing theano by cloning the repository with
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
seems to resolve the issue. Since windows normally does not have git, it can be easily installed (seems to take care of the environment's path variable) from here
https://git-scm.com/download/win

How do I import Zbar into my Python 3.4 script?

I am pretty new to programming, and have never used Zbar before. I am trying to write a simple script that will allow me to import Zbar and use it to decode a barcode image. I already have a script set up to decode text from images that uses Pytesseract and Tesseract OCR, but I need to be able to decode barcodes as well. I have Windows 7 32 bit, and and am using Python 3.4. I have already installed Zbar and have used it from the command line successfully to decode their barcode sample. I have tried using >pip install zbar, but I keep getting the error:
"fatal error C1083: Cannot open include file: 'zbar.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe' failed with exit status 2"
Getting the pytesseract OCR was painless but I have wasted a lot of time on this barcode portion of it, any help or alternatives would be much appreciated.
Seven months later you accepted the best answer, a simple solution for
python3.4+ on Windows OS appeared. A ctypes-based wrapper around the zbar barcode reader, a package named pyzbar. If you are on Linux, you need to install libzbar0 but you said you are using Windows and the zbar library is included as dll with the Windows Python wheels. Today, all you need to do is launch:
pip install pyzbar
References for the package:
https://pypi.python.org/pypi/pyzbar
https://github.com/NaturalHistoryMuseum/pyzbar/
I thought I'd share my explorations and discoveries in relation to this problem, even though #ltadams21 has found a workaround.
The short answer: You can't. The zbar module is only compatible with Python 2. The incompatibilities are at the level of the Python C API, which is deep magic beyond my ken.
There's a bug report for this. In the meantime, use the os.system workaround that #ltadams21 posted, or maybe try zbarlight instead? (I haven't tried it myself, because it says it only reads QR codes, and I need something that reads EAN barcodes.)
The long answer: You can follow along with these steps, which represent my best efforts to get it working, but (spoiler alert) it still won't work at the end.
(Re)install zbar for Windows (zbar-0.10-setup.exe), making sure to tick the "Development Headers and Libraries" option.
Download and extract the zbar Python package (zbar-0.10.tar.bz2).
Open setup.py in your preferred text editor.
Scroll to the bottom, find the line that starts libraries, and insert a new line below it, like so (checking that the path is the same on your system as it is on mine):
libraries = [ 'zbar' ],
include_dirs = ['C:/Program Files (x86)/ZBar/include'],
Open a command prompt inside the extracted package and run python setup.py install.
Observe that the new errors now relate to PyIntObject and PyInt_Type. Discover that these are Python 2-only objects.
If desperate, try to re-#define them to use PyLongObject and PyLong_Type instead. Fail, because of course it's not that easy. Bang head against keyboard (gently).
Give up, and use the os.system workaround that #ltadams21 posted.
Forget wrestling with all of the wrappers. The easiest solution for me was to simply use
import os
os.system(r'D:\Winapps\Zbar\bin\zbarimg.exe -d d:\Winapps\Zbar\Examples
\barcode.png')
Worked instantly. Hope this helps anyone else struggling with that issue.
As of November 2016, there is the package pyzbar. To import Zbar for python3.4+ on Windows OS, all you need to do is launch
pip install pyzbar
This is possible because pyzbar is a ctypes-based wrapper around the zbar library that is included as dll with the Windows Python wheels.
The ZBar for python says you need to have the ZBar library installed for it to work. http://zbar.sourceforge.net/download.html
I found an easy solution for 3.4+. First install pyzbar
pip install pyzbar.
Then the below should work
import pyqrcode
from pyzbar.pyzbar import decode
from PIL import Image
qr = pyqrcode.create("HORN O.K. PLEASE.")
qr.png("horn.png", scale=6)
decode(Image.open('horn.png'))
print(qr.data)

can't find import go-gtk

I've been playing around with Google Go, I love the power behind it and decided to try out some libraries. I tried using goinstall to install github.com/mattn/go-gtk/gtk but when I try to compile an example I'm getting:
can't find import: github.com/mattn/go-gtk/gtk
I've heard that others have problems with goinstall, is there anything I can do to fix this? I also saw that some people fixed this by putting the path as something like github.com/mattn/go-gtk/gtk/gtk.so but it's still not working for me.
Use:
go install github.com/mattn/go-gtk/gtk
and it will download and install this library in $GOPATH/src
Use following command to install necessary packages
go get github.com/mattn/go-gtk

Resources