GdkPixbuf Linux dependencies - python

GdkPixBuf.pixbuf_get_from_window() does not work on my Linux Manjaro (Cinnamon) machine. The code below (only the screenshot part) did work perfectly to grab a screenshot in my old Manjaro installation, but recently I reinstalled, and now the same code does not work. I even tried the same code in Linux Mint (Cinnamon) but it didn't work there either.
No exceptions occur in the code when I run/debug it with Visual Studio Code, nothing in .xsession-errors and nothing sticks out in the journalctl log.
So I can only guess that some dependency is missing on my new machine that I had installed on my old machine, but without an error message it is hard to find out what is missing. I get no output when I run the application from the terminal. The application works fine, except the screenshot part.
I have installed PyGObject and PyCairo in my virtual environment of course. So there must be another dependecy that I am missing, anyone know what is missing?
[Edit] I don't know if this is a problem with my virtual environment (somehing that I need to pip install) or if it something that is missing on my machine (something that I need to sudo pacman -S). When I had it working on my old machine, I had really just learned about virtual environments and python (still a newbie though), so it might have been working because of something I had installed globally.
from gi.repository import Gdk, GdkPixbuf
class ScreenShotHelper(object):
def __init__(self):
"""Setup the screenshothelper class"""
# Get root window (contains all monitors and windows)
self.root_window = Gdk.get_default_root_window()
def grab_and_scale(self, position, size, requested_size):
"""Grab a screenshot and scale it down to requested size"""
# Get specific area from root window
pb = Gdk.pixbuf_get_from_window(self.root_window,
position.left,
position.top,
size.width,
size.height)
# Scale the image down to the size the user asked for
pb = pb.scale_simple(requested_size.width,
requested_size.height,
GdkPixbuf.InterpType.NEAREST)
return pb

Related

Pyinstaller can not find scipy.special._ufuncs on another computer

I am trying to get setup with a easily distributable python program which happens to use scipy. I have two windows 10 64 bit virtual machines. On one I have installed the dependencies for my program, and it runs correctly. Additionally I have installed pyinstaller and performed a freeze. The program runs correctly as the building user on the first VM, as well as a new user on the first VM. The issue is that I get a error loading dll on the second VM, which I just spun up as a test.
I attempted to find all imports from scipy and include them as hidden imports. I also included the scipy "extra dll".
pyinstaller --windowed --icon="%SCRIPT_FOLDER%\res\icon.ico" --hidden-import=numpy --hidden-import=scipy._lib._util --hidden-import=scipy.special._ufuncs --hidden-import=scipy --hidden-import=scipy.stats --hidden-import=scipy.interpolate --hidden-import=scipy.special --hidden-import=scipy.cluster.hierarchy --paths C:\Users\User\AppData\Local\Programs\Python\Python37\Lib\site-packages\scipy\extra-dll --workpath "%WORK_FOLDER%" --distpath "%OUTPUT_FOLDER%" "%SCRIPT_FOLDER%\..\something.py" -n something
Also, I can see the referenced dll files in the correct spot in the frozen output folder under scipy/special there are _ufuncs.cp37-win_amd64.pyd and also _ufuncs_cxx.cp37-win_amd64.pyd
The error is generated specifically on the line "from scipy import special".
Also of note, though I guess it does not help much, is that I have followed a similar procedure for OSX and Linux platforms with no such issue, and no need for any manual hidden import specification...
Would appreciate any help that you can give to help figure out what is going wrong.

Clicking does not work in Jupyterlab [OS X, chrome]

Bug description:
No response when clicking any buttons except files.
When I want to leave one cell to another, weird jumping back happens.
The demo below is more explanatory.
To Reproduce:
On my mac, basically after opening Jupyterlab, all clicks inside give no responses.
Expected behavior:
A normal and smooth experience like before.
Screenshots:
demo
Desktop (please complete the following information):
OS: [OSX 10.14.3]
Browser [chrome 72.0.3626.119]
JupyterLab [0.35.3]
Additional context:
Jupyterlab worked well one week ago on my OS X 10.11 El Capitan. And then I want to add a plugin (#lckr/jupyterlab_variableinspector). So I need to upgrade my node, npm and thus my OS X. After upgrading them and install the plugin, the problem happens. But I am not sure it is because of the version, because I did not use Jupyterlab in this week and may do something else to my system. I tried to disable the plugin and it did not help.
Problem solved. It was caused by a Chrome plugin with similar functions like "RightToCopy". I just deleted it and reinstalled the Chrome, then everything works well.

Tkinter keeps crashing on Tk() on Mac

I've encountered a problem while attempting to create a Tkinter window using root = tk.Tk() . Every time I get to that point, the program crashes, and "Python quit unexpectedly" message is displayed.
I get no tracebacks at all, so I assume that is the ActiveTcl bug. However, I have the new distribution from ActiveTcl Website installed, which is supposed to take care of the problem (obviously, it doesn't).
Interestingly enough, it only crashes when it is executed in Python 2.7. It works fine in Python 3.6. However, I need to use 2.7.
My MacOS version is 10.12.5.
Any ideas / suggestions about fixing the issue are welcome.
P.S. I have read a good dozen of similar posts before posting this, and not any of the proposed solutions worked for me. Please consider this before marking this post as a duplicate.
I don't know what is meant by "new distribution" for ActiveTcl is but if you're using 8.6, it needs to be downgraded to 8.5.
Also, if you run IDLE which uses Tkinter, do you see any messages warning of "instability"? If you see that then, it means you need to downgrade Tcl to 8.5.
Are you running Python 3 through Anaconda? Tkinter was acting all sorts of funky on me and then I uninstalled Anaconda and now it works fine.
Interestingly enough, I am running a PyCharm Professional / Anaconda combo on a Windows 10 VM on my Mac, and I have issues with Tkinter on it as well. I have absolutely no issues however on my Linux Mint box.
To reiterate, I was able to remove the issue by completely removing Anaconda. (How to uninstall Anaconda completely from macOS)
Tkinter needs to be imported like this in order to work with both python 2 and 3:
try:
import tkinter
except ImportError: # python 2
import Tkinter as tkinter

Mayavi example fails, crashes python on Ubuntu

I'm trying to run a standard Mayavi example. I just installed mayavi2 on Ubuntu (Kubuntu 12.04) and this is my first step with Mayavi. Unfortunately, this step is failing.
The examples I wish to run come from here:
http://docs.enthought.com/mayavi/mayavi/auto/examples.html
For example, this one.
The behavior I am seeing is that the plot canvas area is blank (mostly). The popup window is shown and its controls are present and working.
The only errors I am seeing are:
libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
Where would I add LIBGL_DEBUG=verbose?
I'm on Kubuntu 12.04 with:
Python 2.7.3
IPython 1.1.0
wxPython 2.8
vtk 5.8.0-5
setuptools, numpy, scipy - latest versions (just updated)
I am running the examples in IPython (which seems to be the recommended way). I am using this command to start the shell:
ipython --gui=wx --pylab=wx
I also tried running the examples from within an IPython notebook as so:
%run example.py
In all cases the examples fail to display the animation. The window itself is display as are the controls. But the animation canvas is mostly blank, although a flash of the images will sometimes appear.
At least once previously I saw my attempts crash Python. The message was:
The crashed program seems to use third-party or local libraries:
/usr/local/lib/python2.7/dist-packages/traits/ctraits.so
/usr/local/lib/python2.7/dist-packages/tvtk/array_ext.so
However, I am not seeing that crash now.
I found some important clues here:
https://askubuntu.com/questions/283640/libgl-error-failed-to-load-driver-i965
Like that person, I ended up reinstalling my graphics driver and that solved my problem. (The problem wasn't related to mayavi or python after all.)

Trouble with simple gtk python script

I am new to python and am trying to run a simple program I found on the web. I have installed the pyGTK All In One Download and cannot (after searching on the web for a month or so) find gtk.py anywhere.
It does not exist on my computer no matter how many times i run pygtk-all-in-one-2.24.2.win32-py2.7.msi
Here is my code
import pygtk
pygtk.require('2.0')
import gtk
class Simple:
def destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
win.connect("destroy", self.destroy)
win.set_title("Simple")
win.set_position(gtk.WIN_POS_CENTER)
win.show_all()
Simple()
gtk.main()
I searched this forum and many others as well. If you have this file, could you post the code so I can copy it?
If someone can help I would be very grateful. Thank You for listening.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
It seems that I have found the answer from the following link at http://www.slideshare.net/BaabtraMentoringPartner/importerror-dll-load-failed-is-not-a-valid-win32-application-python-mysql. I uninstalled the 64 bit version and installed the 32 bit version. When I run it from the command line the little window comes up! The error still shows up in Netbeans though so maybe the problem is in the Netbeans IDE?
The gtk code is in
C:\Python27\Lib\site-packages\gtk-2.0
There is no single file named gtk.py. (There is a _gtk.pyd, which is like a dll).
However, you should generally not need to access the source code for the libraries you install. Python will handle that for you when you import gtk, then you can just use those features within your script.
If you have another gtk app (like GIMP) you may have problem with enviroment. Also, I hope that the indentation is broken only here, not in your script. And tell us what is the error.
I guess that using python(64bit ) for Windows 7 was the main problem.
So I uninstalled the 64 bit version and installed the 32 bit version and it seems to work fine now.
Thanks to everyone for your help.
I would like to mark this question as answered but I don't exactly know how.
Uninstall your all-in-one and try with this other all-in-one:
https://sourceforge.net/projects/pygobjectwin32/files/
Then:
import gi
gi.require_version('Gtk', '2.0')
from gi.repository import Gtk

Categories