error: no graphics toolkits are available! octave - graphics

I have installed Octave 4.2.1(CLI) on Ubuntu 16.04 using commands like ./configure,make and sudo make install. When I try to use plot() function,it throws following functions.
Plotting Data ...
error: no graphics toolkits are available!
error: called from
figure at line 86 column 7
plotData at line 6 column 1
ex1 at line 47 column 1
When I tried available_graphics_toolkit().I get following output
octave:17> available_graphics_toolkits()
ans = {}(1x0)

Related

image to osd tesseract error using python 3.6

I m trying to use image_to_osd function of tesseract but I got this error for python 3.6, but when I test the same script in an other environment with python 3.8 it works !!, is there any configuration for python 3.6 or anything to do ?
angle_rotated_image = re.search('(?<=Rotate: )\d+',pytesseract.image_to_osd(rotated)).group(0)
error:
angle_rotated_image = re.search('(?<=Rotate: )\d+',pytesseract.image_to_osd(rotated)).group(0)
File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\pytesseract\pytesseract.py", line 543, in image_to_osd
}[output_type]()
File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\pytesseract\pytesseract.py", line 542, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\pytesseract\pytesseract.py", line 287, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\pytesseract\pytesseract.py", line 263, in run_tesseract
raise TesseractError(proc.returncode, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (1, 'Tesseract Open Source OCR Engine v5.0.0.20190623 with Leptonica Warning: Invalid resolution 0 dpi. Using 70 instead. Estimating resolution as 163 Warning. Invalid resolution 0 dpi. Using 70 instead. Too few characters. Skipping this page Error during processing.')
I ran into a similar problem when trying to determine rotation of a given document and trying to use pytesseract's image_to_osd(). It was working fine for me on MacOS with tesseract 4.1.1, but it wouldn't work on Windows with tesseract 5.0.0-alpha. After reading through many threads on the topic related to the OP's error and trying various things like passing --dpi and -c min_chararacters_to_try= with no success, I finally tried using a different version of tesseract on Windows, which finally solved my problem.
Status of image_to_osd():
(PASS) OS MacOS; tesseract 4.1.1; pytesseract 0.3.0; Python 3.6.5
(PASS) OS Windows; tesseract 4.1.0; pytesseract 0.3.0; Python 3.6.5
(FAIL) OS Windows; tesseract 5.0.0; pytesseract 0.3.0; Python 3.6.5
I think pytesseract 0.3.7 will probably work too, but I didn't test it.
Note that you can still get OP's error with this, but from what I tested it's much more reasonable now, e.g., with blank pages.

Function "collect_vertex_marginals" returns an error on documentation example

I am trying to reproduce an example from the graph-tool documentation on network reconstruction. I noticed that the code changed recently and although it used to return no error before, it now does.
I am running Python 3.6.5 with the graph-tool installed through Docker on Windows OS. Specifically, I have tried running the below code:
1 def collect_marginals(s):
2 global pv, u, cs
3 u = s.collect_marginal(u)
4 bstate = s.get_block_state()
5 b = gt.perfect_prop_hash([bstate.levels[0].b])[0]
6 pv = bstate.levels[0].collect_vertex_marginals(pv, b=b)
7 cs.append(gt.local_clustering(s.get_graph()).fa.mean())
The error message that I get is:
"TypeError: collect_vertex_marginals() got an unexpected keyword argument 'b'"
In the previous version of the function which was running successfully:
a) 'collect_vertex_marginals' in line 6 did not have the 'b' argument
b) line 5 of the above code did not exist.
You are using an older version of the library. You must upgrade to the newest release.

string: syntax error on raspbian jelly, flawless on IDLE windows 8

My script (python 3.6) raises an error when executed on my RPI (Linux raspberrypi 4.9.59-v7+ #1047), but runs flawlessly when executed with IDLE, on a windows 8.1 PC.
Basically, I want to create a gzip archive from "data.json" file.
Here is a light version:
import time
import gzip
inputFile = "/path/to/data.json"
dataArchiveName = f"{inputFile}-{time.localtime().tm_mday}_{time.localtime().tm_mon}_{time.localtime().tm_year}.gz"
...
When I run the script, the following exception is raised:
File "dataManager2.py", line 96
dataArchiveName = f"{inputFile}-{time.localtime().tm_mday}_{time.localtime().tm_mon}_{time.localtime().tm_year}.gz"
^
SyntaxError: invalid syntax
I do not understand why... Any idea ?
Thank you in advance
f-strings were introduced in Python 3.6, since you are using Python 3.5 on you Raspberry Pi, you will have to either install Python 3.6 on it or use older way of formatting strings, this should work:
dataArchiveName = "%s-%s_%s_%s.gz" % (inputFile, time.localtime().tm_mday, time.localtime().tm_mon, time.localtime().tm_year)

RiveScript gives an error for python object macros

Is it possible to access the object macros internally in RiveScript? I'm bit confused with that.
I have defined the following script:
> object small python
return "4"
< object
+ small
- <call>small</call>
Which gives me an error when I enter small:
error: [ERR: Object Not Found]
make a space after the object name just like that
- <call>small </call>
The definition of the object seems to be ok, but you are probably running it from https://play.rivescript.com/ or https://www.rivescript.com/try, which only allow JavaScript or CoffeeScript (see the about page).
You can use rivescript-python to run the code, which you can install by:
pip install rivescript
Then put your rivescript in a file (.rive), for example, in helloworld.rive.
Then in python:
from rivescript import RiveScript
bot = RiveScript()
bot.load_directory('.') # set your directory where the .rive file(s) is/are
bot.sort_replies()
Now you can use bot.reply to get the answer for a certain input:
>>> bot.reply('localuser','small')
'4'
Edit: I have tested this code on Ubuntu 14.04 with Python 3.4.3 and Python 2.7.12 and rivescript 1.14.4.

Python 3 networkx draw_graphviz() does not work

I just want to draw a simple graph with Python 3 networkx & graphviz:
import networkx as nx
G = nx.complete_graph(3)
nx.draw_graphviz(G)
I'm using ubuntu14.04 and IPython3 and as usual I did pip3 install networkx and running the code gave me:
ImportError: pydot could not be loaded: http://code.google.com/p/pydot/
And I tried installing pydotplus and running the code:
/usr/local/lib/python3.4/dist-packages/networkx/drawing/nx_pydot.py in pydot_layout(G, prog, root, **kwds)
294
295 if isinstance(node,list):
--> 296 node=node[0]
297 pos=node.get_pos()[1:-1] # strip leading and trailing double quotes
298 if pos != None:
IndexError: list index out of range
and pydot2 also:
/usr/local/lib/python3.4/dist-packages/pydot.py in write(self, path, prog, format)
1893 prog = self.prog
1894
-> 1895 dot_fd = file(path, "w+b")
1896 if format == 'raw':
1897 data = self.to_string()
NameError: name 'file' is not defined
I spent quite some time searching and installing other pydots and pygraphviz combinations already but still no luck.
While this may be related:
pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible, that doesn't solve the problem in Python 3.
You can fix this by editing the line #292 from:
pydot_node = pydot.Node(make_str(n)).get_name().encode('utf-8')
to remove the encode at the end:
pydot_node = pydot.Node(make_str(n)).get_name() #.encode('utf-8')
I've reported this bug/fix here.
This seems to be the same issue as that the pydot you're using is a version incompatible with Python 3, which uses file(...). file(...) is removed in Python 3 already.
I noticed this issue and setup a Python 3 compatible version on PyPi.
For Linux systems for Python 3.x, try:
pip3 install pydot3
Or in general for Python 2.x, try:
pip install pydot3
Not a very great answer but it acts as a workaround.
First output the .dot file by
networkx.write_dot(G, 'graph.dot') using Python
and then do the appropriate graphviz output command like neato -T png graph.dot > graph.png on the command line.

Resources