Pillow was built without XCB support error - python

I am coding in an Android device using an app called Pydroid3.
I want to use ImageGrab from pillow to take screenshots,I created a python file which takes screenshots using ImageGrab,but when I import it to other python file it shows error "Pillow was built without XCB support".
I imported everything from that file.
How could I resolve it

Related

Converting a Python project to DLL or decreasing the size and imports

I have a python project for OCR MRZ detection with 2 modules 1 is for ID which uses EasyOcr,pythorch and other one is for Passport documents which uses Pytesseract and tensorflow.
I need to prepare this project for deployment I have tried some methods but none of them was practible for deployment process.
I have tried pyinstaller with couple of configurations with --onefile
option the setup is great but it takes too long to unpack the exe
when executed.
I have then tried --onedir option the delay was gone but now
installation package was too complicated and size was too
large(1.8GB).
I have tried to "compile" python code by using Cython but even with a
helloworld.py sample app I couldn't manage to make this one work I
got couple of errors during gcc compiling the last error I got due to
msvcp package which i have installed but still got the error.
And as last I have used Nuitka to get a dll-like file to import this
in C# and use it like a package, I have successfully created a test
.pyd file from a helloworld.py but i couldn't import it in C# as i
planned.
What I need is to prepare this project as a simpler and low-sized application which is hard to reverse-engineered for source codes ready for deployment. For passport OCR I can switch development to C# but for ID I couldn't find any alternative OCR library to get the MRZ information so at least I need to use ID OCR module from my Python project.
Any help would be appreciated,
Thanks

Python pywinauto for Mac for Audacity

I have a working code on Windows which, after a bunch of many other steps, uses Audacity to de-noise the received audio file. I had been using the following code on Windows to transfer control to perform a set of actions:
import pywinauto
from pywinauto import application
def noiseReduce(filename):
app = application.Application()
app = app.connect(path=r'/Applications/Audacity')
app.captcha20170411_202241.menu_select('File->Import->Audio')
app.Selectoneormoreaudiofiles.Edit.SetText(filename + '.wav')
I ported this code to my Mac and installed the necessary Py modules like pywinauto. However, I am getting this error:
File "/Users/gautam/PycharmProjects/project/Capture.py", line 20, in <module>
from pywinauto import application
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pywinauto/application.py", line 75, in <module>
import win32process
ImportError: No module named 'win32process'
On trying to pip install win32process, I am getting an error:
Could not find a version that satisfies the requirement win32process
(from versions: ) No matching distribution found for win32process
Is there a way to resolve this or another alternative to transfer control to Audacity and perform actions on it?
Currently pywinauto doesn't support Apple Accessibility API and shouldn't work on MacOS.
Unfortunately there is no good cross-platform GUI automation tool (using accessibility text-based approach) in the open source field. The only one is LDTP (Linux Desktop Testing Project) and API-compatible Cobra (on Windows) and pyatom (MacOS). Fortunately pyatom is a standalone self-contained library as well. My students were able to automate few apps using pyatom. You may consider using it for now.
P.S. We're trying to make pywinauto cross-platform (with real seamless integration), but MacOS backend implementation is on the very early development stage for now. I expect to introduce Linux AT-SPI support earlier than Apple Accessibility API one.

Python version of AddFontResource()

I'm currently trying to install fonts across a bunch of servers. I've been able to use a script to copy the fonts over and "install" them onto the server but I need to be able to access the fonts without having to turn off the server or log off the account.
I found Windows AddFontResource() which is done using C++, but is there an equivalent function in Python or Powershell?
(I've been using Python and Powershell to do checks and installations.)
Have you tried using the win32api library? It has the SendMessage() function which can be used in conjunction with the windll.gdi32.AddFontResource() in ctypes
For example installing a TTF font file:
import win32api
import ctypes
import win32con
ctypes.windll.gdi32.AddFontResourceA("C:\\Path\\To\\Font\\font.ttf")
win32api.SendMessage(win32con.HWND_BROADCAST, win32con.WM_FONTCHANGE)

Specifying path to a library for a unix executable, outside of the executable

I have downloaded an unix executable 'gtselect' used for analysing scientific data. This comes as part of a larger package of tools with installation instructions such that 'gtselect' can be called from the current working directory.
When I just run 'gtselect' everything works as expected.
I then use a python script 'gt_apps.py' which uses GtApp to wrap the tools as python objects
from GtApp import GtApp
filter = GtApp('gtselect')
and then use a different script 'run.py' to call gtselect as a python object and run it:
import gt_apps
gt_apps.filter.run()
When I run this, I receive the error
dyld: Library not loaded: libdataSubselector.dylib
Referenced from: path/bin/gtselect
Reason: image not found
Now, the library it is trying to load is instead found at
path/lib/libdataSubselector.dylib
I have tried setting
export DYLD_LIBRARY_PATH = path/lib/
but the same error persists.
Any advice? Thanks

Tkinter OpenGL context in Python

I need to create an OpenGL context in Tkinker, for using it with PyOpenGL Python module.
Tkinker doesn't natively support OpenGL context, but I found this page on PyOpenGL docs, explaining how to use a wrapper included in the module for this:
http://pyopengl.sourceforge.net/documentation/context/
I tried to run the provided code but I got a message saying TOGL module was not found.
I downloaded the module from http://togl.sourceforge.net/, but couldn't get it to work.
PS. I did the test on Mac OS X, with Python 3.2, using virtualenv.
PyOpenGL provides Python bindings for the Tk OpenGL widget (Togl) but not Togl itself, that is why you had to download it. Now, to install Togl is easy but there isn't a tool ready to perform the task. Since the Python bindings will use Tcl to load the Togl module, the widget needs to live in one of the directories present in Tcl's auto_path, which is where Tcl looks for loading libraries. What you can do is start a Tcl interpreter, tclsh, and check which are these directories by doing puts $auto_path. In my case I copied the directory lib/Togl2.0 (inside the Togl's .tar.gz) to /opt/local/lib/tcl8.5. You can also extend auto_path to look for other directories, but I'm not covering that here.
Then I tested using Python 2.7 on Mac OSX. Doing import OpenGL.Tk tries to load Togl, too bad it fails. The reason is that Togl comes precompiled for i386, since I built Python as a universal binary all I did was run it as arch -i386 python2.7, and now import OpenGL.Tk works.

Categories