Why keep getting the same error in PyCharm 'error running Unknown error'? - python-3.x

I'm working on PyCharm, but I keep facing the same problem error running Unknown error from time to time.
I already updated it to the latest version. Moreover, I got the system crash in the middle of the training, and it gets stuck on Waiting for process detach. Also, when I close it and rerunning it, it shows Could not load dynamic library.
Update:
Adding to the problem above, sometimes, I can not see any output on the console. I have reinstalled it, but without any success.
New Update
After updating the PyCharm from 2021.1.1 to 2021.1.2, it seems that the problem has been solved.

Related

create exception when python command generates a program.exe has stopped working type error

I am facing a problem with a program i am developing in Python 3.6 under Windows 10.
One particular command generates an unknown error, windows throws a 'program.exe has stopped working' message and the program exits.
The command is a 3d-model loader that is part of another python package (Panda3D). The crash is always associated with this command (and more particularly with a specific dll of the loader) and a particular file that it tries to open.
Since i cannot locate and therefore solve the faults in the dll (probably there is a bug there) i would like to just pass the problematic file and continue to the next one. But since python exits and i do not know the error type, the typical try, except does not work.
So, i would like to know if there is a way to predict this type of behavior in my code and prevent the program from exiting.
Many thanks for any help.
The pop-up "Program.exe has stopped working." can be caused by a variety of things and therefor there is no "one size fits all" type solution. But if you're certain that your problem is cause by a specific line of code you can always try something along the lines of :
try:
loader.loadModel("c/path/to/your/file")
except Exception as e:
print(e.message, e.args)
# your error-handling code here
Make sure the file path that you're giving to loadModel respects the following :
# WRONG:
loader.loadModel("c:\\Program Files\\My Game\\Models\\Model1.egg")
# RIGHT:
loader.loadModel("/c/Program Files/My Game/Models/Model1.egg")
Source : pandas3d official documentation

Running Selenium in container brings sudden selenium errors where there were none before

Whenever I run my tests on my computer, they work relatively fine. At the very least, selenium runs without problems.
As soon as I run the same tests on a docker container I start running in all kinds of errors that selenium started throwing, such as: "Element not clickable at point...", "Element is not interactable...", etc.
None of these happen when I run the tests on my computer normally.
I have a Linux Debian 9 computer, docker 1.11, Chrome 72.0, chromedriver 2.41, selenium 3.12. Test are done using py.test and in headless chrome.
My Dockerfile is simple, installing all of the packages for python and putting my tests in there and running them. I run a custom-made Dockerfile and don't have the option to use the premade seleniumHQ ones.
I have first tried running a demo test where I first encountered that problem. I managed to solve it by editing the test code to bypass the exception and trying again. After that succeeded, I tried running a few more complicated tests and kept running into different errors I didn't run into before.
Every solution I found was aimed at solving the thrown exception, but I suspect there's a deeper issue at hand and I can't figure out what it is.
To reiterate: running tests on my computer (both headless and otherwise) works like a charm, but running the same tests in a docker container fails with several selenium errors thrown. For some reason, the tests don't seem to run properly and selenium keeps throwing errors.
I've been trying to solve it for a while now and can't seem to figure out what the problem is.
I'd like to know WHY this problem occurs and how to solve the root cause of it. If it's a known issue and the solution is indeed simply to solve every exception as it comes, I'd like to know that too.
As far as I could find, and how I solved this, is to just follow the exceptions and fix them as they come.
The general problem areas I encountered were the click event on buttons/textbox and clearing the text from a textbox.
The solution involved:
A call to webdriver.execute_script('arguments[0].click();', element) to replace button click events.
A call to webdriver.execute_script('arguments[0].focus();', element) to replace textbox click events.
A call to webdriver.execute_script('arguments[0].value = "";', element) to replace textbox clears.
From where I stand, these solved most if not all the sudden exceptions and the rest worked as intended.
I have encountered similar problems when running Selenium with chromedriver, suddenly elements being unclickable, not visible on the page etc. The solution was to disable /dev/shm usage by adding --disable-dev-shm-usage to the Chrome arguments.

What does "Gdk-WARNING **: gdk-frame-clock: layout continuously requested, giving up after 4 tries" mean?

When I run the gtk3 python code using pygobject in Ubuntu 18.04, the code runs without any warnings. But when I build it on Ubuntu 16.04 for snap, I am getting these warnings:
Gdk-WARNING **: gdk-frame-clock: layout continuously requested, giving up after 4 tries
There is no part of the code that tries to refresh the screen even twice within a second(unless there is some check_resize events). I am unable to understand what is causing this error. I don't have a Ubuntu 16.04 with me. so I can't debug either.
Steps to reproduce
Install the edge release from the snap.
sudo snap install --edge halo-weather
and run it.
halo-weather
It's an opensource project of a simple weather application named Halo. Here is the entry point python script.
Can somebody give me some directions?
The error generally means you are directly trying to modify the UI out of sync with GTK thread.
So we need to make sure that all UI updating functions are not directly called and instead queued to be called by Gtk using any of the following:
GLib.idle_add(callback, ...)
GLib.timeout_add(interval, callback, ...) # X milliseconds delay
GLib.timeout_add_seconds(interval, callback, ...) # X seconds delay
Hope that will help someone.

Python 3.7: Pygsheets get all record stopped working

I have several scripts using pygsheets to get information from google sheets. Today they have stopped working without any errors or exceptions being noted.
Debuging Attempts:
Tried running in different ways
1. Visual Studio Code - just stops working no errors or exceptions. Debugged to line (wks = sh.worksheet('title', tabs))
2. command prompt - pops a window up that states "Python has stopped working: A problem caused the program to stop working correctly. Please close the program"
3. manually in IDLE - locks up at (wks = sh.worksheet('title', tabs))
4. Ran code on a different machine: worked fine.
So, I know it has to do with something on my machine, but not sure where to start looking. Any suggestions are welcome.
import pygsheets
from pygsheets import Worksheet
gsheet = pygsheets.authorize(service_file = 'client_secret2.json')
sh = gsheet.open('Google_file_name')
wks = sh.worksheet('title', 'tab_name')
results = wks.get_all_records()
The last line is where everything stops. Again, no errors or exceptions.
I know this doesn't really solve the issue, nor do I have experience with pygsheets, but from my experience with gspread the issue appears to be connection-related. I have had this exact issue with gspread's get_all_values module and, as you experienced, it suddenly stops working without any changes to the code and without terminating or returning any errors. The issue often disappears when the program is run again minutes or days later.
The only other time I have experienced freezing/hanging (recently in Python) is with TCP connections...

Compile error when running on another machine

I am having a problem with a workbook. It works fine on my machine but when it is run by someone else it is giving a problem with an error message "Compile error can't find project or library"- thing is, it is doing it on a Mid$ string command!
Anyone know what could cause this? Is there a setting they need somewhere? The code was written in Excel 2010 and they are running Excel 2010
This is caused when you have a missing reference. Have a look in Tools > References on the machines that are throwing the error. You should see that certain references are prefixed with MISSING.
These libraries will need to be installed on the other machines in order to use them, alternatively, you could try late binding if they have an earlier version of the reference you are using.
If the above doesn't work, I have experienced this problem when there is a failed installation on the machine. None of the references are missing, but upon opening Excel a (usually unrelated) application gets stuck in a failed install loop. If this is what is happening, you'll need to rectify the failed installation.

Resources