I have my project installed as a windows service and everything worked smoothly. I had some errors with using venv and pywin32, but eventually figuret that out. Stackoverflow link
However when I use pyinstaller to make onefile executable from it problems start occuring.
I use following command to create executable:
[Path_to_my_venv_pyinstaller] --onefile --hidden-import win32timezone myservice.py
Then I am executing it from cmd with install arg, service is installed.
However next step, executing it with start arg fails. Error message:
Starting service [Service_Name]
Error starting service: The service did not respond to the start or control request in a timely fashion.
So I tried debugging it with ``debug``` argument. It works normally, when I install service without executable, from source files. When service is installed from executable I am getting following error.
Debugging service [Service_Name] - press Ctrl+C to stop.
Traceback (most recent call last):
File "[Service]\[Service_Folder]\service.py", line 48, in <module>
File "lib\site-packages\win32\lib\win32serviceutil.py", line 640, in HandleCommandLine
File "lib\site-packages\win32\lib\win32serviceutil.py", line 461, in DebugService
AttributeError: module 'servicemanager' has no attribute 'Debugging'
[14252] Failed to execute script service
I found similar topic on stack, unanswered, link here. So the problem indeed lays in installing service from pyinstaller executable.
I have no idea, how to track error on this, Event Viewer does not display anything more than i could see from console.
Is there other way to debug a service?
Related
I made an app that uses tkinter and tkinterdnd moudles. It works completely fine when I launch it as a script, however when I try to make and executable file from it and laucnh it, foloowing error ocures:
Traceback (most recent call last):
File "TkinterDnD2\TkinterDnD.py", line 53, in _require
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "IxcomGUI.py", line 128, in <module>
File "IxcomGUI.py", line 11, in __init__
File "TkinterDnD2\TkinterDnD.py", line 285, in __init__
File "TkinterDnD2\TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.
[14512] Failed to execute script 'IxcomGUI' due to unhandled exception!
I tried following:
Installed tkinterdnd2 with pip install and built with pyinstaller myscript.py.
Manually installed tkinterdnd2 module as shown in this video https://www.youtube.com/watch?v=JIy0QjwQBl0&t=605s&ab_channel=RamonWilliams and built with pyinstaller myscript.py
Repeated previous step, but added this thing https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
Tried to implicitly tell pyinstaller path to tkdnd module with specifying path to the module with --paths flag.
All this attempts led to error bellow. Does anyone know some kind of solution?
The issue here is that Drag n Drop requires two components: the TCL libraries and the Tkinter interface to them. I install both manually to config my environment. (See my answer to How to Install and Use TkDnD with Python Tkinter on OSX?). I know someone packaged something on PyPI for the TkinterDnD2, but I haven't looked into it.
I have a project which uses TkinterDnD2. I build it with PyInstaller and see the same error you see (more or less). Running PyInstaller with the --onedir option (rather than the --onefile option), I saw that tkdnd2.8 was missing from my dist directory.
To rectify this, on Windows, I added
--add-binary "C:/Python/Python38-32/tcl/tkdnd2.8;tkdnd2.8"
to the PyInstaller command line, and that did the trick. I can now build a --onefile executable, and it runs without error.
Apparently it was unnexpectedly easy to fix this issue. All you need to is to get to the <YourPath>\Python39\tcl directory and find tkdnd2.8 directory, and move it to the tcl8.6 directory. I have also renamed it to just tkdnd, however I don't know whether it's necessary.
Here is the original link that saved my day: http://pyinstaller.47505.x6.nabble.com/tkinter-TclError-can-t-find-package-tkdnd-td2330.html
I'm using tkinterdnd2 installed from pip, and not TkinterDnD.
What really worked for me was this flag:
--add-data "C:/Users/myName/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/tkinterdnd2;tkinterdnd2"
It expects tkdnd to be a folder inside tkinterdnd2. Just using additional-hooks/hidden import on tkinterdnd2 and tkdnd did now preserve that subfolder structure.
I am new to Python Flask and Python.
I use Python 3.7 and Ubuntu.
I have done export FLASK_APP=emptst
And have been executing an online application. It was running fine
In the same environment I have a pure python program & I executed it from command prompt.
I think while executing this the python flask server was listening. It is a localhost server
After this I have stopped the server and ran the python online again.The server came up But it started executing the python program that I executed from command line.
And when I removed the program from the mflask directory it is giving the following error.
Traceback (most recent call last):
File "/home/ss/anaconda3/envs/test/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/ss/mflask/emptst_new.py", line 2, in <module>
import recognize_faces_video_file1_200119
ModuleNotFoundError: No module named 'recognize_faces_video_file1_200119'
Pls advise. Basically i need it to run the online application emptst and not execute the batch application which it executes currently, whenever i start the server
I have a requirement whereby the navigation and control of a legacy application has to be automated - this automated method, packaged as a script, would need to be deployed via SCCM to our user base.
After some research, I've decided to use Python's PywinAuto module to achieve my goal.
I've managed to create a script that automates all the GUI steps as required and I've also packaged this script as an exe using the Pyinstaller module, but the issue i'm now having is the following: when running locally on both Windows 7 and Windows 10 machines, the exe executes successful. However, when triggering the exe remotely through either SCCM or PSEXEC, the exe fails to execute.
I've also wrapped the exe in a powershell script, but the same thing occurs when executing the script via PSEXEC or SCCM.
I'm running PSEXEC as the System user, which has full admin rights. The SCCM user has full admin rights aswell.
This is the Pyinstaller example script that I packaged into an exe, just for testing purpose:
from __future__ import print_function
import logging
from pywinauto import actionlogger
from pywinauto import Application
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--log", help = "enable logging", type=str, required = False)
args = parser.parse_args()
actionlogger.enable()
logger = logging.getLogger('pywinauto')
if args.log:
logger.handlers[0] = logging.FileHandler(args.log)
app = Application(backend='uia').start(r'mspaint.exe')
dlg = app.window(title_re='.* - Paint')
dlg.close()
When running the exe locally from the the command line, the following appears indicating successful execution:
c:\Temp>pywinauto_test 2019-05-11 07:47:14,215 INFO: Started
mspaint.exe application. 2019-05-11 07:47:14,344 INFO: Closed window
"Untitled - Paint"
When running remotely through psexec, the following appears:
C:\Temp>pywinauto_test.exe 2019-05-11 07:29:38,221 INFO: Started
mspaint.exe application. [ 5516] Failed to executC:\Temp>e script
Pywinautopaint Traceback (most recent call last): File
"site-packages\pywinauto\application.py", line 256, in
__resolve_control File "site-packages\pywinauto\timings.py", line 458, in wait_until_passes pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "Pywinautopaint.py", line
59, in File "site-packages\pywinauto\application.py", line
378, in getattribute File
"site-packages\pywinauto\application.py", line 259, in
__resolve_control File "site-packages\pywinauto\timings.py", line 436, in wait_until_passes File
"site-packages\pywinauto\application.py", line 201, in __get_ctrl
File "site-packages\pywinauto\findwindows.py", line 87, in
find_element pywinauto.findwindows.ElementNotFoundError: {'title_re':
'.* - Paint', 'backend': 'uia', 'process': 2844}
All known methods to run GUI automation remotely are listed in the Remote Execution Guide. It's not specific to PyInstaller or other py2exe-like tools. Mostly it's OS Windows restrictions and RDP features that can be workarounded by several ways.
Also ElementNotFoundError is often raised when default timeout to find window (5 sec.) is insufficient. For example, if remote virtual machine is slow. This might be unrelated to common remote execution problems.
I am trying to run the appengine-endpoints-helloendpoints-python app locally using the google cloud platform SDK (which has been added to my path) using the command dev_appserver.py from the command line. It used to run perfectly, but now when I try, I get an error:
Error processing line 2 of
/Users/hannah/anaconda3/envs/py27/lib/python2.7/site-packages/grpc_google_pubsub_v1-0.8.1-py2.7-nspkg.pth:
Traceback (most recent call last):
File "/Users/hannah/anaconda3/envs/py27/lib/python2.7/site.py", line 161, in addpackage
exec line
File "<string>", line 1, in <module>
KeyError: 'google'
Remainder of file ignored
It's in a anaconda python2.7 environment. I've tried looking in site.py but I can't follow it back to a clear missing link.
The appcfg.py command used to deploy from the command line doens't work at all anymore. The command is not found.
bash: appcfg.py: command not found
As I said, I reinstalled and authorised the google cloud SDK and it is added to my path and that hasn't solved anything.
Oh finally, the error comes up whenever I run the dev_appserver.py command, not just with the example code from google.
Any tips would be appreciated
I'm new to Google App Engine and I followed multiple video tutorials (One from Udacity) and for some reason I am unable to get it to run on the local host with the simple "Hello World" program.
I do have the Python SDK installed as well as the Google App Engine program installed. I did modify the YAML file so that it matches with my application (it did by default). When I click "run" in the Google App Engine launcher, it shows a yellow triangle caution sign next to the program I'm attempting to run.
When I type the localhost:8080 in the search bar it says:
This webpage is not available
I've also tried reinstalling both Python 2.7.9 and the Google App Engine and to no avail. In short I would like to understand why the program shows no content when I attempt to run it. Here are the log files if it's any help:
2015-03-14 18:36:21 Running command: "['E:\\Python\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'C:\\Program Files (x86)\\Google\\google_appengine\\new_project_template']"
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
NameError: name 'execfile' is not defined
2015-03-14 18:36:21 (Process exited with code 1)
It looks like the default pythonw on your system (E:\Python\pythonw.exe) is some version of Python 3. That's where execfile is indeed not defined (and the GAE launcher's incompatible with Py3 in other ways, anyway, at this time).
To verify, run E:\Python\python.exe at a cmd prompt -- it should greet you with a version banner which I bet will mention Python 3.something.
Where did you (re-)install 2.7.9? How's your PATH environment variable? Likely with E:\Python before wherever 2.7.9 is installed.
Simplest might be to change your PATH so that wherever 2.7.9 is installed comes before E:\Python...!