PyQt4 - "See the log file for details" error - python

I have made an application using Python and recently i found that i can use py2exe to make executables for windows.
The problem is that a library i am using (xmpppy) produces this error
DeprecationWarning: the md5 module is deprecated; use hashlib instead
and when i try to run the executable a dialog appears saying this
See the logfile 'C:\Python26\P2E\MyApp\dist\MyApp.exe.log' for details
any ideas how to fix that?

You can try including the following lines down import sys
sys.stdout = open(“my_stdout.log”, “w”)
sys.stderr = open(“my_stderr.log”, “w”)
For more information you can read this

when a python script .py has any error it shows in console but when you run python .exe file it genrates .exe.log file when error accured.so go to your folder and see that there is a .exe.log file is there showing errors.

Related

Run an .exe file from python code with path parameters

This throws file not found error, I guess because of the path argument. The path argument is needed for the clemb.exe, which is a batch runner for the stream. Even when I try to run it without the path arguments I get access dennied. I am currently running this from pycharm but I want to compile to a binary and ship to customer.
Any suggestions how to bypass the file not found error and the access denied issue?
import sys
import subprocess
subprocess.call([r'"C:\Program Files\IBM\SPSS\Modeler\18.2\bin\clemb.exe -stream path\to\spss\modeller\stream\stream.str"'])
I am using Python 3.7
I guess
subprocess.call([r'C:\Program Files\IBM\SPSS\Modeler\18.2\bin\clemb.exe', '-stream', r'path\to\spss\modeller\stream\stream.str'])
should be more clear and working.

Python: no module named 'bottle-websocket' when running an executable made with PyInstaller, including Eel module

I was playing around with the eel module for Python - gives an opportunity to run HTML + CSS/JS with the python functionality.
Made a simple program, tried to make an executable out of it via PyInstaller.
No errors whatsoever, but when running this executable it crashes on the first line - import eel, telling - there is no module called 'bottle-websocket'.
I checked pip: eel, bottle-websocket are installed. Can't figure out what's the problem. Attachments:
main.py:
import eel
from os import path
eel.init(path.dirname(__file__) + "/web")
eel.start('main.html', block=False)
while True:
eel.sleep(10)
Error:
Picture with the error while I try to start the exe
EDIT:
PyInstaller Log
I was also having this same issue, but I finally fixed it, it was actually very very easy, first of all make sure you are using auto-py-to-exe to package your app.
After inserting necessary details (script file,, extra files etc), you would see an advanced options tab probably below, click on it to expand it, look for the hidden imports label and insert "bottle-websocket" in the input field representing the hidden imports, that's basically all you need to do
I HOPE THIS HELPS
Took me the whole day figuring out the solution, but finally, here it is:
Copy the plugin.py, server.py files from C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bottle_websocket to C:\Users*YOUR_USERNAME*\AppData\Local\Programs\Python\Python36-32\Lib
Make sure you have this line as follows in your *.spec file generated by PyInstaller (FOR PYTHON 3.6 32bit):
datas=[('C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eel\eel.js', 'eel'), ('PATH_TO_YOUR_WEB_FOLDER', 'YOUR_WEB_FOLDER_NAME')]
3)Run this command in cmd: python C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eel\main.py HERE_SHOULD_BE_THE_PATH_TO_YOUR_WEB_FOLDER
this command will get the 'bottle-websocket' work and will make sure that it complies with the web folder and files.

Python Executable "Opened With..." (Windows)

I've made a little Python (3.x) script and compiled it to a *.exe file using Py2Exe.
What I would like is to click on a random file in explorer and "open it with..." (using the right mouse button) my executable. My program can then use the path of the selected file.
I know such information is typically passed into 'argv[...]', however, it is not working. I only get one argument, the full path of the .exe file.
For now the program only creates a *.txt file with all the passed arguments.
Could anyone help me out?
Thanks in advance.
The full code:
import sys
filename = "Test.txt"
file = open(filename, 'w')
file.write('Number of arguments: ' + str(len(sys.argv)) + ' arguments.\n')
file.write('Argument List: ' + str(sys.argv))
file.close()
I now tried adding an input line at the end of my script to prevent it from closing instantly and I noticed an error in the panel: "ImportError: No module named 'ctypes'". Some searching showed this is a bug in py2exe: How to stop Python program compiled in py2exe from displaying ImportError: No Module names 'ctypes'
The mentioned solution solved the error and after rebuilding the *.exe passing in the file path works! So it was a py2exe bug all along...

How can I import a Python script with several modules included into Sikuli

I'm trying to call a Python (2.7) script from Sikuli (r930) and use a variable from the script. Below is the Python code:
import sys
import re
import os
import time
from pywinauto import application
from SendKeys import SendKeys
from cStringIO import StringIO
app=application.Application()
app.connect_(path=r'C:\Program Files\myApp\myApp.exe')
backup = sys.stdout
sys.stdout = StringIO()
app.dlg.print_control_identifiers()
out = sys.stdout.getvalue()
sys.stdout.close() # close the stream
sys.stdout = backup # restore original stdout
regex = re.compile(r'(\d{8}\s*\-\s*\d{8})')
found = re.search(regex, out)
print found.group(0) #pass this variable to Sikuli
I'm capturing stdout because this is what Pywinauto's print_control_identifiers method returns (not a string). Also, I need a hashed serial number from the GUI app that I can't get with Sikuli, hence the need to use Pywinauto. However, when I attempt to call execfile() from Sikuli, I get the error:
ImportError: no module named Pywinauto.
I read the docs, and I know that Sikuli (Jython) can include Python modules and scripts. Besides, the external .py file that I'm calling runs successfully when ran independently. Can someone tell me if I'm missing a step?
Code I'm using to call the .py file shown above from Sikuli:
aScript = 'c:\\getHash_serial.py'
execfile(aScript)
The immediate problem you're having is that Jython can't find your module. Probably, you installed it under Python, and they don't share a module path. You can fix this by setting the JYTHONPATH environment variable.
However, Pywinauto links with native code, and this is something that Jython does not support.
You may be able to get around this limitation by calling regular Python from Jython via the subprocess module.

Python subprocess module equivalent for double-click in Windows

I want to open a file using the subprocess module as though the file was double-clicked in Explorer. How do I do that?
I tried the following line:
subprocess.call("C:/myfile.csv", shell=True)
which throws an error saying:
The syntax of the command is
incorrect.
'C:\' is not recognized as
an internal or external command,
operable program or batch file.
How do I emulate a double-click using subprocess? Basically I want to open a CSV file in Excel 2007.
os.startfile(r'C:\myfile.csv')
(Win32 only. For Mac, run a process with 'open filename'; on Linux/freedesktop-in-general, 'xdg-open filename'.)
I think part of your problem is you're using a unix style slash / as a path separator, instead of the windows backslash . It looks like windows is interpreting /myfile.csv as an argument for the program C:, which is why you're getting that message.
However if you corrected that, I think you'd just get it saying that C:\myfile.csv isn't a program.
I know that this is a bit late, but to do that in python 2.x (not sure about 3) you should use the subprocess module, referencing Popen. Here is the code:
import subprocess
subprocess.Popen(r'explorer /select, "C:\"')
It basically opens the file, and then opens it in the default program.

Categories

Resources