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.
Related
When doing
import dbm.gnu
on a standard Python 3.7.6 (64) for Windows, I get:
File "C:\Python37\lib\dbm\gnu.py", line 3, in
from _gdbm import *
ModuleNotFoundError: No module named '_gdbm'
Isn't dbm.gnu supported out of the box on Windows?
The same problem happens with:
import dbm.ndbm
File "C:\Python37\lib\dbm\ndbm.py", line 3, in
from _dbm import *
ModuleNotFoundError: No module named '_dbm'
I tested on another Python 3.6.8, and it's the same.
This has always been the case (that gdbm and ndbm are not supported on windows). See also issue 3769 for background and dbm and windows, and issue 3783 for something to work on if you want to contribute to making the dbm story on windows better.
Googling found a gdbm port to windows, so if you are trying to use source files from linux, that might help you. We're open to suggestions on improving the situation here, but someone has to figure out what would make sense and champion it. Bundling the gdbm windows port is probably not an option, but making it possible to install something via PIP that will work is, if there's anything in core preventing that currently.
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
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)
I'm using Mountain Lion at the moment.
I've installed Blender (because it's a dependency of OpenGrasp), and downloaded OpenGrasp. However, I try to load the robot editor up and I get this:
$ python GraspRobotEditor.py
Traceback (most recent call last):
File "GraspRobotEditor.py", line 34, in <module>
import Blender
ImportError: No module named Blender
How do I point Python to the Blender python interface? the Getting Started guide doesn't instruct you much here.
(I'm sure this is a trivial problem to solve but I'd like to see this documented on StackOverflow anyway.)
From the error you it can't find the python module Blender which represents the python hook to Blender. So there could be a few This could be any number of reasons to do with your setup.
The first is that the Blender module is runtime generated whileBlender is running. The specific 'Blender' module used is part of the Blender 2.4x series. According to the link you provided there, they mention porting to newer versions but checking their snv the code is definitely written for 2.49.
Blender 2.49b was the last stable release - http://download.blender.org/release/ Ensure you are using that.
The next thing is whether it can be run via the the Run Script command
TL:DR
Start up blender
Switch to the text workspace
Open the script and see if it can be run directly.
If not you will need to install the folder to the Blender modules directory of your install and then try running it.
Edit: Was looking at into the SVN some more and there does appear to be a version 2 for blender 2.5+ which can be put into a zip file and installed via the add-on installer. According to the bl_info it was build for 2.58 but what support level you would need to try out yourself.
I am using python 2.6.5 on an Ubuntu intalled server.
I need to integrate an API for our applicaion, in that case, i needed to use a DLL given to me by the API provider. Their example of code about api integration is written in Visual Basic... I made a search on google and found some examples of using ctypes , and i try using cdll and pydll, which caused the following error...
OSError: /home//some.dll: invalid ELF header
One possibility is using IronPython, but i do not have much information about ironpython so i am not sure if it will handle my needs completely..
Is there any available module that let me use that dll on python (or aynthing that i am missing from the exixting ones). It is hard to upgrade my python version?
DLLs may be windows creatures, but if a DLL is 'pure .NET' and doesn't utilize executables specific to windows etc., then it can work often in Linux, through Mono. (mono ipy.exe).
Ironpython's System and similiar windows modules are customized to be os agnostic (to a untested degree).
I have successfully run NHibernate, FluentNHibernate, log4net, and a few other commonly used DLLS in Ubuntu.
import clr
import sys
sys.path.append(os.path.abspath('./DLL')) #where your dlls are
clr.AddReference('System')
clr.AddReference('FluentNHibernate')
from FluentNHibernate.Cfg.Db import PostgreSQLConfiguration
The key seems to be to import DLLs in this fashion. If a dll imports another (fluentnhibernate imports nhibernate), you don't need to import Nhibernate for example.
DLLs are Windows creatures. The only way you'll be able to use a DLL is by using a Windows build of Python. You'll be able to run Windows Python on Ubuntu by having Windows installed inside a virtual machine. You also might be able to run it using Wine.
An alternative, of course, is to ask your API provider if they have a Linux version of the API.
First, check if your DLL is a .NET Assembly file. An "Assembly DLL file" has nothing to do with the assembler. It's simply a way the .NET framework stores its bytecode inside a DLL file!
Do file library.dll in Linux. If it says something like this:
PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows
then you're lucky: it's an assembly file. You can run it on Linux.
Install Mono. Install Python.NET. Forget IronPython: it's dead.
Now, in Python.NET, you can do this:
import clr
clr.AddReference('./library.dll')
# the library has just registered a namespace we can use
from LibraryName import *
but how do you know what to import?
Auto-complete.
Or use monop tool to inspect the DLL like this:
$ monop -r library.dll
Assembly Information:
LibraryName
Version=9.9.3.0
Culture=neutral
PublicKeyToken=null
LibraryName.ClassName
...
$ monop -r library.dll LibraryName.ClassName
public class ClassName {
public ClassName (string inputString);
...
}
and it will tell you everything about that library