Exe created on virtual server with PyInstaller fails to execute - python

I have created an exe using Pyinstaller with python virtualenv, I am able to do this in the normal python environment without any problems, however when creating it on a virtual server the exe once created fails to execute (open).
I have created the exe with the following debug options,
Scripts\pyinstaller --debug=all --log-level=DEBUG
There is nothing in the log that indicates any specific error.
However when I try to open the exe, In the Tracing process while clicking through the different windows, the following message pops up:
'
[49852]: LOADER: Error activating the context: ActivateActCtx:
An Attempt to set the process default activation context failed because the process default activation context as already set.
It allows you to click "OK" through the rest of the messages and then:
I have tried to trace and debug and find the error, however I have not had much success, there are no missing modules or errors in the log.
I am using Python 3.7.4
Any help would be appreciated.

Related

Requests_html render() returning WinError 14001 on VSCode

I'm working on a web scraping project using Python. I'm using the requests_html library. My problem is identical to one that someone else had . When I run
r.html.render()
I get an error that says
OSError: [WinError 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail`.
On the other thread I linked, someone said that the issue is with chromium and that I should reinstall requests & Python. I did a reinstallation of Python (both from VSCode and from the Python website) as well as reinstalling requests. However, I am still receiving this error when trying to run my code. Does anyone have any advice on what I can do?
Go to command prompt as admin and run sxstrace.exe.
sxstrace.exe Trace -logfile:tracefile.etl
run your program until error occurs then go to the cmd window and press Enter key.
Then run
sxstrace.exe Parse -logfile:tracefile.etl -outfile:tracefile.txt
this will output a file into your System32 directory. Find it and post contents of the .txt file here. It should contain information on what is wrong.
I got this error after initially installing python via the Microsoft App store. I uninstalled that instance of python and reinstalled it using an installer from python.org and that resolved the error. There was one error on the very first run of my code when the initial chromium download was triggered by the call to render() but after that it worked.

Xcode can't attach to PyCharm debugging process

I have a c++ library that I can debug in Xcode.
This library is 'bridged' to python via SWIG. I have some python code running, making calls to the library. In PyCharm I can debug the python version.
I would like to debug the c++ code that is called by the python function, using the Attach to Process feature of Xcode, in order to
check that the python call is correct, and
the arguments are passed as expected.
So, I start debugging the Python code from PyCharm, stop at a breakpoint (early) in the python code, identify the Python PID using os.getpid(), then in Xcode I try to attach to that process. However I get an error:
"error: attach by pid '61889' failed -- attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)"
In the console I can't see any message about why it was denied.
Any idea? Is it a setting in PyCharm? In Xcode? In the system?
My setting: Mac OS 10.15, Xcode 12.4, PyCharm 2020.1; Python 3.7

Fatal error detected "Failed to execute script main".Works with pyinstaller, crash with HM NSIS

I tried to execute a try except command on the app to get log of the error but it still crash so I think it is a problem of PATH ? library ?
Why does it work with pyinstaller and not after I created an installer.nsi with HM NSIS edit ?
I'm sorry but I have no idea of how to debug it !
It is a "simple" project. tkinter app, excel creation, 1 thread...
I don't know from where it comes from (I'm not good in system and OS).
PS: even stranger, when I install the app with Install.exe, if I decide to launch the app directly it works !!!
But it never work a second time when I use the shortcut or the .exe in C:\Program Files (x86)\MYDIRECTORY.
This a permission problem, I tried to write on a protected file.
Solution to debug:
do not use --noconsole when you run pyinstaller, it will let you the console and with windows+G, you can keep track of the error even if the terminal stop immediatly after the crash of the programm.
(I tried to register the error in a .json in a try except but that the thing that made my program crash !)

Pyinstaller "Failed to execute script pyiboot01_bootstrap"

I'm using pyinstaller to produce an exectuable for a python program. But, whenever I try to use a generated executable, I get a message window that reads "Failed to execute script ...".
The command I'm running is pyinstaller -w run.py. But, when run with the --debug option a different error is made apparent. "Failed to execute script pyiboot-1_bootstrap". After this error it kills the program.
I tried with the -F option and that did not change the outcome. All the files I created for the project are in the same directory. I did get warnings that dll's weren't being included but I resolved that.
Pyinstaller doesn't like the built in quit() function I was using.
Instead use sys.exit() to close the program.
See this question to see why sys.exit() is better practice for production code.
What I found useful was to make an exe of my .py script in console mode and then run it. For a very short period of time, I saw an error message in the console window. I had to screenshot it to read completely. So one of the imports was missing from the folder in which I had my script. I opened cmd from the location bar of that folder (by typing cmd there) and imported modules using pip install <module_name>.
Sorry for the long answer, I am a newbie.

Running spark-submit from pycharm

I am trying to figure out how to develop apache-spark program in PyCharm.
I have followed article in this link.
I define SPARK_HOME and add pyspark to Python path well. There is no error
in importing pyspark modules and autocomplete works fine.
However I get an error on defining SparkContext when I run the program in PyCharm.
Error: Must specify a primary resource (JAR or Python or R file)
Run with --help for usage help or --verbose for debug output
...
...
Exception: Java gateway process exited before sending the driver its port number
I managed to run the program on terminal with submit-spark.
Do I need to change the configuration on PyCharm or Is there anyway to run
submit-spark instead of python in PyCharm?
If you are fine by terminal submit-spark you can add a run configuration that does that for you. Otherwise you can see some configuration in Edit Run/Debug Configurations window as well. This post in particular can you get you there.

Categories