204 questions
2
votes
2
answers
107
views
How does multiprocessing.Pool() create its child processes?
Overview:
I am trying to use a Pool internally in a module that is not __main__ and make it invisible to main that this pool exists.
Because of this, if __name__ == "__main__": protection is ...
2
votes
1
answer
59
views
Calling `sys.excepthook` manually with `sys.last_exc`
The signature of sys.excepthook is
sys.excepthook(type, value, traceback)
so a natural way to call it is
sys.excepthook(sys.exc_type, sys.exc_value, sys.exc_traceback)
But as of Python 3.12, ...
5
votes
1
answer
192
views
Python 3.12 Generic syntax and undefined variables
I just stumbled across this weird thing with python 3.12.
I have a type I import under if TYPE_CHECKING:.
When trying to reference this type without quotes, I expect a NameError, because the variable ...
0
votes
0
answers
45
views
Yocto: zstandard python interface load issues
I'm trying to add an image for python3-zstandard to my yocto build. I know that it's included with versions of meta-python past Walnascar, but I'm on Scarthgap which does not include it. Basing the ...
-1
votes
1
answer
114
views
How to install a compatible version of TensorFlow Federated on Google Colab (Python 3.12 + TensorFlow 2.19)?
I am using Google Colab, which comes with:
Python 3.12.11
TensorFlow 2.19.0
When I try:
!pip uninstall -y numpy jax jaxlib
!pip install tensorflow_federated
Pip starts backtracking and tries to ...
2
votes
0
answers
67
views
f2py from numpy 2.3.2: Linking a fortran 77 code with many subroutines in separate files fails
I have a large fortran 77 code, "NSCool", distributed among many files which I compile into a python package using f2py. It used to work nicely with python 3.7, then it took me weeks to have ...
0
votes
0
answers
70
views
Redpanda container with SSL configured failed to communicate with producer client at python-slim container
producer log:
ERROR:kafka.conn:<BrokerConnection client_id=kafka-python-producer-3, node_id=bootstrap-0 host=redpanda:9093 <handshake> [IPv4 ('172.22.0.2', 9093)]>: Closing connection. ...
2
votes
0
answers
67
views
Are `openpyxl` and `pyodbc` mutually exclusive?
A recently upgraded Ubuntu server (to 24.04) now uses Python3.12.
Several Python programs stopped working after upgrade. The problem arose as soon as a connection to the MySQL database was asked.
...
0
votes
0
answers
80
views
After python and ansible upgrade getting error "/bin/sh: /bin/env python: No such file or directory"
I upgraded python and ansible on an env after which started getting error "/bin/sh: /bin/env python: No such file or directory" in ansible-playbook execution, below are the upgraded versions
...
1
vote
0
answers
60
views
nltk.FreqDist.plot fails to display plot
I'm trying in vain to make NLTK show a Frequency Distribution Plot using FreqDist.plot(). I've followed the steps from the first chapter of the NLTK book (scroll down to "3.1 Frequency ...
0
votes
1
answer
134
views
Pyinstaller issue in python 3.12 while importing setuptools._distutils.compilers
I am working on a project using python3.12 which involves compiling .py files to binaries using Pyinstaller.
After compiling, when i try to invoke binary I face following error
File "...
0
votes
1
answer
54
views
ModuleNotFoundError: No module named 'distutils' in dockerpycreds when using wandb with Python 3.12 (Conda)
When using the latest version of wandb in a Conda environment with Python 3.12, an error is raised due to a dependency on the distutils module—which has been removed in Python 3.12. The error ...
0
votes
1
answer
334
views
Has anyone been able to get Python 3.12 to run corrrectly in Google Colab?
I am trying to get Google Colab running with Python 3.12. I ran the following:
!sudo apt-get update -y -qq
!sudo apt-get install python3.12 -y -qq
!sudo update-alternatives --install /usr/bin/python3 ...
1
vote
1
answer
127
views
Why doesn’t Python 3.12.6 raise ValueError on slice assignment length mismatch? [duplicate]
I came across unexpected behavior in Python 3.12.6 while performing slice assignment.
Here’s a minimal example:
l3 = [2, 3, 4, 5]
l3[::1] = [1, 3]
print(l3)
Since l3[::1] selects 4 elements ([2, 3, 4,...
2
votes
0
answers
42
views
Type checking a callback protocol for subclasses of Python enum
I'm updating the type annotations in my code for compatibility with Python 3.12. I'm taking the opportunity to enable strict type checking in VS Code (i.e. pyright).
I have a subclass of enum, which ...
1
vote
2
answers
817
views
Dataflow call: httplib2 transport does not support per-request timeout. Set the timeout when constructing the httplib2.Http instance
I am working on updating python version to 3.12.0 in my cloud function. After upgrading, Dataflow call was outputting the following message:
httplib2 transport does not support per-request timeout. ...
1
vote
1
answer
82
views
Why does sklearn GaussianMixtures spawn a cmd window when run from IDLE?
When I run this code using IDLE in windows, it spawns a temporary cmd window that disappears shortly thereafter.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.mixture import ...
0
votes
0
answers
236
views
AttributeError: module 'cryptography.hazmat.bindings._rust.openssl' has no attribute 'hashes' when using ccxt with Binance API
I'm developing a Flask web app that uses the ccxt library to connect to an API. When trying to run my application, I'm encountering this error:
AttributeError: module 'cryptography.hazmat.bindings....
0
votes
0
answers
46
views
Comparing strings received as bytes
I'm running a python script that receives data over a TCP connection. This connection can send multiple messages that consists of multiple variables which have multiple data types. When a string is ...
0
votes
0
answers
36
views
Waitress does not run when trying to execute explicitly with a specific Python version
We have to manage several Python versions for several requirements and we have three different Python versions: 3.8, 3.11 and 3.12. When executing the Waitress server with a specific version, it does ...
0
votes
0
answers
97
views
Converting Beanie Document Types
I'm trying to get used to Beanie with Mongodb. The Problem that I'm running into is this:
I cannot convert Documents of different types while retaining the revision_id.
The necessary sample code:
...
0
votes
1
answer
216
views
How to declare property in abstract base class intended to be used with Pydantic field?
I several types of Widgets in my App. All share an interface I_Widget, including a read-only property "public_property".
I want some of them to use a member instead of the property.
from abc ...
3
votes
1
answer
157
views
Sphinx - autodoc imported data with own docstring
The situation
I want to use the Sphinx autodoc features to document a Python API that is implemented in the following way.
I have a module that is used to expose various symbols (functions, constants, ...
0
votes
1
answer
104
views
Why can't I see the image equally spaced to the right with python turtle?
I'm trying to create the Breakout game with python's turtle module, but for something I haven't yet identified I can't center the image correctly!
from turtle import Turtle
class Game():
def ...
0
votes
1
answer
70
views
How to Convert Grey Elements to Black in SVG Generated from DXF generated usign ezdxf
import logging
import re
import xml.etree.ElementTree as ET
from ezdxf.addons.drawing import Frontend, RenderContext, svg, layout, config
import ezdxf
class ImageGenerator:
def __init__(self, doc) ...
1
vote
0
answers
682
views
TensorFlow Installation Fails on Python 3.12: Compatibility Issues with Python Versions
I'm trying to install TensorFlow , but I keep encountering installation issues due to Python version compatibility. I’m using Python 3.12, but I get an error message indicating that TensorFlow doesn’t ...
1
vote
0
answers
1k
views
Couldn't build wheel for pillow
first time coding in python and I need to add Pillow to edit some images, yet every time i try to install it I get the same error.
This is the only library in which I've had any issue.
I'm using a ...
1
vote
1
answer
90
views
Python Flask-Healthz should I use Blueprint, Flask configuration and/or Entension?
It's unclear and confusing to me whether Blueprint and Flask configration is required if I use the extension Healthz(app)!?! The confusion comes from the README line:
The rest of the configuration is ...
0
votes
1
answer
60
views
Python 3 relative imports behave differently between local run and on k8s
I have the following structure:
project/
|- src/
|- __init__.py
|- package/
|- __init__.py
|- module1.py
|- module2.py
Let's say module1.py ...
0
votes
2
answers
46
views
Python subclass constructor calls metaclass with *args and **kwargs
I am trying to instantiate a singleton with constructor argument. However, passing the input arguments to the metaclass hits an error.
from typing_extensions import List, TypedDict, Optional, Any
...
1
vote
1
answer
234
views
Running cqlsh on Ubuntu 24.04 returns "ModuleNotFoundError: No module named 'cqlshlib.serverversion'"
I recently upgraded my Ubuntu from 22.04 to 24.04 using the Ubuntu upgrade, and now when I tried cqlsh it gives me following error:
Traceback (most recent call last):
File "/usr/bin/cqlsh.py&...
2
votes
2
answers
60
views
Python Pandas extract "range" object column values to 2 other colulmns with int type
I have a column with dtype = object. It has either NaN or 123 - 456. I need to extract min and max into it's own columns:
import numpy
df["min"] = df["values"].map(lambda x: ...
-1
votes
1
answer
2k
views
IPython.display does not show any image at all but <IPython.core.display.Image object>
I am trying to show LangChain graph in my python module code. Not Jupiter notebook. However, the following code snippet:
from IPython.display import Image, display
from langgraph.graph import ...
0
votes
1
answer
350
views
Python LangChain with Google google_vertexai or google_genai using API KEY?
How to use google_vertexai or google_genai with LangChain in Python? I get the following error:
USER_AGENT environment variable not set, consider setting it to identify your requests.
Traceback (most ...
2
votes
1
answer
127
views
apache spark-submit to local k8s cluster fails despite having the necessary edit rbac setup
I have created the necessary serviceaccount and clusterrolebinding with edit clusterrole but still fails to submit to a local k8s cluster:
$ spark-submit --master k8s://https://127.0.0.1:16443 --conf ...
0
votes
1
answer
41
views
nltk.NaiveBayesClassifier.classify() input parameter
I have the following trained classifier:
classifier = nltk.NaiveBayesClassifier.train(features[:train_count])
When I try to use it to classify():
result = classifier.classify(feature)
and feature is ...
-1
votes
1
answer
83
views
Having issues installing discord
I am using python==3.12.9, tried installing using command pip install discord.py
# first error i encountered was
C:\Users\khanh\AppData\Local\Temp\pip-build-env-ak7vjcgm\overlay\lib\python3.12\site-...
-1
votes
1
answer
130
views
After I changed to python 3.12 I got the error ModuleNotFoundError: No module named 'distutils' [duplicate]
The error that I see on terminal when I run my djanogo server on my instance
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib....
0
votes
0
answers
475
views
ERROR: Package 'example_package' requires a different Python: 3.10.12 not in '>=3.12'
I am trying to set up a package from a github repo. My default python in the conda environment is python 3.12. The pyproject.toml of the repo has the following lines:
[project]
name = "...
0
votes
0
answers
57
views
python pytest quart post request with csrf token
How to test POST request, especially to an endpoint which checks for csrf token?
@pytest.mark.asyncio
async def test_fibonacci_pass(client):
response = await client.post('/fibonacci', data=b"...
0
votes
0
answers
34
views
pytest -v ModuleNotFoundError
I have the following structure:
|- src/
|- common/
|- controllers/
|- models/
|- __init__.py
|- test/
|- __init__.py
|- some_test.py
I am using python 3.12.7 and pipenv. ...
-2
votes
1
answer
107
views
How to match "C", "C++" or "C#"? [duplicate]
I have the following test cases:
CPP_CSHARP_REGEX_TEST_CASES = [
("C++", True),
("C#", True),
("C+", False),
("C##", False),
("C", ...
0
votes
0
answers
41
views
(typo, closed) flask-mail google SSL " smtplib.SMTPServerDisconnected: Connection unexpectedly closed "
So, now that I added SSL instead of TLS there's at least some progress, but it still doesn't work.
I click the button, it processes for a 5-10 seconds and I get the error that connection unexpectedly ...
2
votes
1
answer
4k
views
No module named 'boto.vendored.six.moves' in python 3.12
I am upgrading my project from python3.9 to python 3.12. I do use boto in my project to connect with s3 and all
I keep getting below error
from boto.vendored.six.moves import filter, http_client, map, ...
0
votes
0
answers
68
views
sklearn.cluster KMeans creates a status heap memory corruption error 0xC0000374
I have Windows 11 Home 24.2 Python 3.12.8 PyCharm Community Edition 2024.3 venv with pip 24.3.1 Numpy 2.2.1 Scikit-learn 1.6.1 Scipy 1.15.1 threadpoolctl 3.5.0 joblib 1.4.2
Python installation is ...
0
votes
0
answers
47
views
Error installing pip packages due to error in launcher and wrong python version [duplicate]
When I try to get a pip package such as mexc_sdk for python 3.13, I get the error: pip install mexc-sdk Fatal error in launcher: Unable to create process using '"C:\Python312\python.exe" &...
1
vote
1
answer
1k
views
Trying to install pygraphviz, and get an error related to "building wheel"
I get an error when installing pygraphviz on a Windows 11 Pro ver 22 H2 and build 22621.2283 machine:
C:\Windows\System32>pip install pygraphviz
Collecting pygraphviz
Using cached ...
0
votes
0
answers
35
views
minimization: number of coordinates in coordinate file does not match topology
I am trying to make a CG membrane using Insane with python3.
To make the membrane, I downloaded all the required files and installed insane.
Then I modified the lipids.dat file to add the coordinates ...
0
votes
0
answers
306
views
Using python 3.12 generics and mypy
I want to achieve something like this:
from collections import deque
from typing import Iterable
import numpy as np
def mean[T](a: Iterable[T]) -> T:
s = sum(a)
return s * (1.0/len(a))
c =...
0
votes
0
answers
23
views
I'm trying to figure out how to configure hypercorn logging using a custom logger and format [duplicate]
I managed to make it work after 2 days using the .py configuration file. Here is the code along with a minimal format.
# Hypercorn configuration file
import logging.config
# Server binding options
...