I have an R script that I run on a linux server (Debian Wheezy 7.7). This script is meant to do some computations and generate plots into PNGs. Unfortunatelly I get an error:
> savePlot("myplot", "png")
Error in savePlot("myplot", "png") :
can only copy from 'X11(type="*cairo")' devices
How do I get around this? I am only connected from Win XP with PuTTy, I don't have any X-windows set up on my XP and I don't want to bother with this - all I need is to run the script and produce the PNGs. Thanks!
You may have more luck calling the device internally:
png("plot.png")
plot(1)
dev.off()
If you don't want to bother with opening an instance of R, you could save the above script (e.g. "script.01.R") and run the following from the console:
R CMD BATCH script.01.R
This should also work to create the .png.
On my Ubuntu distribution, calling x11() before plot() resolved this issue. This blog post gives more details on different operating systems.
Related
Some packages like w3m-img, fim, lsix etc can be used to show the images directly on the terminal itself on linux.
I am not talking about converting the image into an ASCII character version and showing it but the image itself which looks proper without any the artifacts.
so how do these programs actually draw the images onto the terminal?
I've used Feh in the past. It should be already installed on popular Linux distributions. To use it, simply do the following:
feh your-image.jpeg
I am having trouble with using the python curses module for windows. I have used the wheel found here to get a script I had written on my mac to run on my desktop. For now, the script just displays a border around the window using the screen.border() method and another line across the whole width of the display. I displayed the bar across the screen using this:
dimensions = screen.getmaxyx()
screen.addstr(dimensions[0]/2, 0, "-"*dimensions[1])
I ran this in a loop, resetting dimensions each time and using getch to check for a curses.KEY_RRESIZE and then running screen.erase() to allow me to resize the window and the script will still work. When I ran this on windows after installing the wheel for python 3.7 (win32 because the amd64 one gave an error) I found that screen.getmaxyx() always returned the same value: the initial screen size, and never changed when I resized the window. I appreciate any help if anyone knows a way to fix this issue, or if I simply cannot use curses on windows, an alternative library for windows. Thank you!
Call resize_term(0, 0) after you get a KEY_RESIZE. (I’m not sure of the exact Python mapping.)
That ("on windows") is probably using PDCurses, which doesn't have a way to automatically update the screensize (e.g., as done with POSIX-based ncurses's SIGWINCH handler). Rather, it detects the window-size change and the application can call is_termresized to decide whether to tell the library to change the data structures to match using resize_term.
The python wrapper doesn't use that.
I have a python program where I try to send a document to a printer. It works fine in my machine with a local printer set as the default printer and connected with my laptop via USB. However, when I tried it with another computer with its default printer being in a network it doesn't work. The error I get is:
pywintypes.error: (31, 'ShellExecute', 'A device attached to the system is not functioning.')
The piece of code is giving problems is the following one:
win32api.ShellExecute(0,"print",doc_path,None,".",0)
I think the problem is because of the printer being connected using the network and not the USB, but it might be another thing.
Thanks for any help.
I found the cause of the error: the computer didn't have a pdf reader installed and that was causing that error (the file to print was a pdf).
Installing Foxit reader (and making it the default program to open pdfs) fixed the problem.
I've got this error when executing a simple print() command but in a command window with utf-8 enabled via the following commands:
chcp 65001
set PYTHONIOENCODING=UTF-8
This caused the error; probably because the string python tried to print on the terminal was in a different encodign than utf-8.
I had the same problem. Simply installing a pdf reader wasn't enough though, I had to make it the default program to open pdfs too to get it to work.
I followed the steps from skia site for compiling skia r1236 on my Ubuntu 12.04 64 bit machine.
When i run the tests , no window comes up to show the graphical result.The output on console is :
[1/33] PDFPrimitives...
...................
[33/33] BitmapCopy...
Finished 33 tests, 0 failures.
If i put a Bitmap to a file using SkImageEncoder::EncodeFile , i do get graphical output on the file. This confirms that the library is working fine but is not able to invoke linux window system.
Another problem is that while running text , i get following error
SkFontHost::OpenStream failed opening 1
--- no context for glyph 0
I have installed all freetype libraries as described by the Skia website , but still have error whichever path i use in SK_FONT_FILE_PREFIX.
My "/usr/share/fonts/" folder have
cmap
truetype
type1
X11
I noticed there is a file SkOSWIndow_Unix.cpp but nobody seems to be calling it from the test code.So my question is
1) How do we get the output to be shown on a window?
2) WHat should be the value of SK_FONT_FILE_PREFIX?
PS : The Windows port worked fine
Skia r1236 is at least two years old; you should be using something newer. The directions on the website are less than a year old.
The Linux tests and the Windows tests produce the same thing. You should see the same result from Linux as you did from Windows.
Part of the question is which particular tests you are running. From your description of the Linux shell output, these were the "gm" tests, which do not display windows. They draw pictures onto off-screen canvases.
With the "-w " option, gm will write the images as pngs into a directory.
With the "-r " option, gm will read images from a directory and compare them to the images it generates.
The SampleApp application in Skia does use the Linux window system. However, we do not support the "views" library that was used to create it. Skia is a platform-independent rendering engine; you'll need to provide your own windows management.
Note that gm functions a bit differently since somtime in the 6000s or 7000s; a default checkout will no longer contain the reference images for all GMs on all platforms.
Our application runs some commands in a headless mode using frame buffer display. We can't rely on fact that Xvfb is installed on every machine, but we suppose that X server is, so we bundle Xvfb binary into our application. The problem is that on some machines, when running bundled Xvfb we get the following fatal error:
could not open default font 'fixed'
Is there a way to bundle basic fonts as well, and point Xvfb binary to them, or is there a more elegant solution to this?
Thanks!
There is a more elegant solution coming up in the future, it is called Xdummy and is the ability to use a real X11 server with the dummy driver to get a virtual screen backed by a real server (Xvfb is barely maintained nowadays). More details (and packages) here, it is based on Xdummy by Karl Runge but is much cleaner (no shared library tricks)
This will be part of Xorg server 1.12 (due shortly)
Until then, you could wrap Xvfb in a little script which figures out where the fonts are on the system (there aren't that many places) and adds the -fp string default font path argument to the command line.
Modern versions of libXfont from X.Org have the basic "fixed" and "cursor" fonts builtin, but until the more recent versions (I believe Xorg 1.7 from 2009), you needed to specify "built-ins" in the font path explicitly for Xservers like Xvfb to find them.