When checking the compatibility of the software I use with Python 3.11, I stumbled upon some issue where I am not sure how to solve or debug it. There already is a corresponding issue in the upstream project, but no apparent solution: https://github.com/hsnr-gamera/gamera-4/issues/54.
The library is partially using the Python C API to increase the performance. The build process does not error out, but as soon as the shared object should be imported, the following error is raised:
tests/test_color.py:3: in <module>
from gamera.core import *
/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/gamera-4.0.0-py3.11-linux-x86_64.egg/gamera/core.py:51: in <module>
from gamera.gameracore import UNCLASSIFIED, AUTOMATIC, HEURISTIC, MANUAL
E SystemError: initialization of gameracore raised unreported exception
Python 3.10 seems to work fine here. There seems to have been a similar issue regarding Python 3.11 within psycopg2 (see Fedora bug tracker), so this might be related to changes in Python 3.11. The build environment is Ubuntu 20.04.5 through GitHub Actions, while I did some local tests with Ubuntu 22.04 as well.
As there does not seem to be much guidance on how to tackle such issues, the following questions arise for me:
How can these failures be debugged and fixed in a general manner? Following some basic tutorials on how to use GDB with Python did not help me much here, although my experience is rather limited there.
Is there any known change from Python 3.10 to Python 3.11 which would cause such issues?
Related
I have a python package that acts like a wrapper for a .dll written in C#. The binary is imported into python by the pythonnet package. Thus, the user can access the functionality of the so called cs_backend.dll conveniently from the python side. The import looks as follows:
import clr as __clr
import System as __System
__clr.AddReference(PATH_TO_CS_BACKEND + "\\cs_backend")
import cs_backend as __csb # exception thrown here
However, it seems that python can't import the .dll as I get a ModuleNotFoundError: No module named 'cs_backend'.
The odd thing is that this error only occures when running the code from Spyder. Executing exactly the same code from Visual Studio Code works perfectly fine.
Do you have any idea what the problem could be?
system specifications
os: windows 10
.net framework v4.5.1
python 3.8.5
spyder 4.2.1
Edit:
I have found a github issue on the pythonnet repository that describes a similar (although not quite the same) problem. However, since it has been open for about 3 years, it seems that there is little to no progress on that.
Edit 2:
There is a similar question here on stack overflow. The solution was to install a newer .NET Framework. This is not my problem since with any IDE other than Spyder the code works just fine. Thus, I guess that this is mainly a Spyder issue.
Currently, it seems that there is neither a solution nor an effort to resolve this problem.
It looks like the problem is caused by the IPython console integrated in Spyder.
A simple workaround is to execute the python script from the system console.
In Spyder this can be done by going to Run - Configuration per file - Execute in external system console.
With the new configuration it is at least possible to run the script.
Premise: I use Python 3.9.0 on a MacOS with Mojave (version 10.14.5).
The paper "Network Inference via the Time-Varying Graphical Lasso" by David Hallac, Youngsuk Park, Stephen Boyd, Jure Leskovec comes with a Python code which can be found at https://github.com/davidhallac/TVGL. I tried to run the file exampleTVGL.py with Python IDLE but I have the following issues:
It seems to be written in Python2 language, so I converted it in Python3 language with 2to3 command in the terminal;
Then, when running exampleTVGL.py I got the error:
"SyntaxError: import * only allowed at module level"
which I tried to solve by replacing:
from <modulename> import *
with
import <modulename>
*** update: not even this point is working, cannot substitute like this in order to import all from a module; How, so?
Then two modules were missing (snap and cvxpy), so I installed them in the terminal;
Last I got the error:
NameError: name 'TUNGraph' is not defined
I see that David Hallac himself on GitHub issues page suggests to solve the error by installing snap package, but on my computer the requirement is already satisfied and still not working.
What am I doing wrong? I tried use Python2, but was not able to install it, although not sure this would be sufficient to solve all issues. How can I solve the NameError 'TUNGraph" problem? Do you have any suggestion on how could I run more efficiently the code without experimenting issues?
Thank you
I am trying to run a GUI test using pytest and pywinauto. When I run the code normally, it does not complain.
However, when I am doing it via pytest, it throws a bunch of errors:
Windows fatal exception: code 0x8001010d
Note that the code still executes without problems and the cases are marked as passed. It is just that the output is polluted with these weird Windows exceptions.
What is the reason for this. Should I be concerned?
def test_01():
app = Application(backend='uia')
app.start(PATH_TO_MY_APP)
main = app.window(title_re="MY_APP")
main.wait('visible', timeout=8) # error occurs here
time.sleep(0.5)
win_title = f"MY_APP - New Project"
assert win_title.upper() == main.texts()[0].upper() # error occurs here
This is an effect of a change introduced with pytest 5.0.0. From the release notes:
#5440: The faulthandler standard library module is now enabled by default to help users diagnose crashes in C modules.
This functionality was provided by integrating the external pytest-faulthandler plugin into the core, so users should remove that plugin from their requirements if used.
For more information see the docs: https://docs.pytest.org/en/stable/usage.html#fault-handler
You can mute these errors as follows:
pytest -p no:faulthandler
I had the same problem with Python 3.7.7 32-bit and pytest 5.x.x. It was solved by downgrading pytest to v.4.0.0:
python -m pip install pytest==4.0
Perhaps all Python versions are not compatible with the newest pytest version(s).
My workaround for now is to install pytest==4.6.11
With 5.0.0 the problem occurs the first time.
W10 box.
Have this problem using pytest 6.2.5 and pytest-qt 4.0.2.
I tried np8's idea: still got a horrible crash (without message).
I tried Felix Zumstein's idea: still got a horrible crash (without message).
Per this thread it appears the issue (in 'Doze) is a crap DLL.
What's strange is that pytest-qt and the qtbot fixture seem to work very well... until I get to this one test. So I have concluded that I have done something too complicated in terms of mocking and patching for this crap 'Doze DLL to cope with.
For example, I mocked out two methods on a QMainWindow subclass which is created at the start of the test. But removing these mocks did not solve the problem.
I have so far spent about 2 hours trying to understand what specific feature of this test is so problematic. I am in fact trying to verify the functioning of a method on my main window class which "manufactures" menu items (QWidgets.QAction) based on about 4 parameters.
At this stage I basically have no idea what this "problem feature" is, but it might be the business of inspecting and examining the returned QAction object.
I'm getting a segfault ("Illegal operation (core dumped)") for a python program that I've run every week without fault for ages. I'm also running Ubuntu on Nitrous. I recall dealing with these yonks ago when coding in C, and I haven't had to deal with them very much recently.
Importing the library urllib3 seems to be causing the problem. Does anyone know a fix?
Also, can someone advise or link to the best workflow for diagnosing these problems in future?
Thanks!
"Illegal operation"
This usually means that you are running code compiled for a more capable processor (e.g. Haswell) on a less capable one (e.g. Ivy Bridge).
Importing the library urllib3 seems to be causing the problem.
On my Ubuntu machine, import urllib3 loads libssl.so.1.0.0, libcrypto.so.1.0.0 and _ssl.x86_64-linux-gnu.so. These crypto libraries are very likely to be compiled with AVX, AVX2, etc. instructions which your processor may not support.
best workflow for diagnosing these problems
Your first step should be to find out which instruction is causing the SIGILL. To do so, run:
gdb python
(gdb) run
>>> import urllib3 # do whatever is necessary to reproduce SIGILL
(gdb) x/i $pc
(gdb) info sym $pc
The last two commands above should give you the instruction that is causing the SIGILL, and the library in which that instruction is used. Once you know what that instruction is, you can verify that your processor doesn't support it, and contact the distributor of the "guilty" library to get a different compilation (one without using instructions that are not supported by your CPU).
I've installed mesos 0.26 successfully on a vm machine.
The installation has been performed on an ubuntu trusty thar system
by following this manual:
https://open.mesosphere.com/getting-started/install/
So far so good. I wanted to write a tiny python framwork.
For this I need to install the eggs via easy_install:
(I've downloaded the eggs accordingly for the trusty thar ubuntu and the 0.26 mesos):
wget http://downloads.mesosphere.io/master/ubuntu/14.04/mesos-0.26.0-py2.7-linux-x86_64.egg
easy_install mesos-0.26.0-py2.7-linux-x86_64.egg
all went fine, however, if I start python in the shell
and type in
import mesos.interface
I get the message: ImportError: No module named interface
As someone suggested, it may be that there is no longer a binding for python, or that they have renamed the API calls. Well, I looked in the version updates here:
http://mesos.apache.org/documentation/latest/upgrades/
Since the transition from 0.19.x to 0.20.x there hasn't been any changes regarding the mesos.interface part, or at least they are not mentioning it here.
To increase the confusion I also get the following error message when I'm typing in python: import mesos.native
There I receive: ImportError: No module named interface.mesos_pb2. To put it into a nutshell: what is going wrong here, and how can it be fixed? And yes, I've googled various web pages, with terms such as "mesos python bindings", mesos +api +python, etc. And yes, I have also consulted the official mesos webpage. There are nice refences for Java and C++ but not for python, or at least they are very well hidden.
Thanks in advance for any hints.
Solved. For what reasons ever:
export PYTHONPATH=${PYTHONPATH}:/usr/lib/python2.7/site-packages/
is required to set the PYTHONPATH. After that step it works like a charm.