2,266 questions
2
votes
1
answer
56
views
Can't use lock around gather in Python asyncio
For some reason, this code doesn't work on Ubuntu 20, Python 3.8.10, unless the .gather line is commented out.
It works on Ubuntu 24, Python 3.12.3 and Windows 11, Python 3.13.9.
It doesn't work on ...
0
votes
0
answers
205
views
Starlette/FastAPI Default Exception Handler Overriding Error [duplicate]
I'm trying to override the default exception handler in a FastAPI application so I can log any exceptions that happen. The problem that I run into is that my handler seems to run as it logs what I ...
0
votes
0
answers
68
views
Building wheel for mysqlclient (pyproject.toml) did not run successfully
I'm trying to install mysqldb on python3.8 (Windows 11 24H2).
I initially had issues with VSC++14 but I managed to solve them.
pip install -U flask_mysqldb
error: subprocess-exited-with-error
...
0
votes
2
answers
76
views
Mock a module that export a class in python
We're working on a message-based communication mechanism. We have several classes that manage incoming messages and send outgoing messages at a high level (Commands, Queries, and Events).
Underneath, ...
-2
votes
1
answer
215
views
How to set up same SSLContext in Python 3.8 through 3.13? [closed]
My code so far:
def _ssl_context(self, ca: str | None) -> ssl.SSLContext:
# NOTE: ssl.create_default_context() doesn't allow setting the context.protocol in a way
# that's the ...
-2
votes
1
answer
327
views
Object is not subscriptable in Scrapy Fake User Agent
I got this error:
from fake_useragent import UserAgent
File "D:\Kerja\HIT\Python Projects\Ongoing Projects\Andrew Mancilla\mancilla-env\lib\site-packages\fake_useragent\__init__.py", ...
0
votes
1
answer
73
views
Why I am unable to create connection with MySQL using python
The program terminates automatically without throwin any error or output
The port and connector working fine and details are given below
C:\Users\jsr>pip list
Package Version
--------...
-1
votes
1
answer
48
views
ModuleNotFoundError when referencing folder in Python [duplicate]
I have a Python3 project arranged as follows:
C:\automation\framework\constants.py
C:\automation\tests\unit-tests\test_myunittest.py
In my unit test, I'm trying to call methods in framework folder, ...
-2
votes
1
answer
73
views
Local package isn't recognized even with __init__.py
Original question
Current project setup is
project/
├─ ams/
│ ├─ __init__.py
│ ├─ common/
│ │ ├─ dataclasses.py
│ │ ├─ __init__.py
├─ entry_point/
│ ├─ bar_api/
│ │ ├─ swagger/
│ │ │ ├─ ...
3
votes
1
answer
11k
views
Can't fix "ModuleNotFoundError: No module named 'setuptools.extern.six'"
I've been trying to test out a colony counter code I found on GitHub that could be of use. However, the windows that generates when i run the code aren't the same as the ones that are demonstrated in ...
0
votes
2
answers
135
views
How to mock psycopg2.connect when used with closing of contextlib module?
I have following class Database with get_data method. It uses 'closing' of 'contextlib' module to close the connection.
class Database:
def __init__(self) -> None:
self.db_details = {&...
0
votes
0
answers
78
views
facing error: no module pycaret.utils.generic while executing pycaret.classification import *
PyCaret is having lots of issue. python 3.8 support PyCaret versions. I am using PyCaret 2.3.6.
It is compatible with numpy version lesser than 1.20 . I am using PyCaret 2.3.6. and Numpy 1.19.5 in ...
2
votes
1
answer
605
views
Python 3.11 (and 3.12) broke custom logging level
i have this custom logger that extend the classic levles to our organization needs
import logging
from config import cfg
from json import dumps
from pydash import map_
import pathlib
import re
class ...
1
vote
1
answer
239
views
My while true loop which is supposed to count to 100 with breaks isn't working
I was supposed to create a while true loop. The program should be counting to 100, printing each number. However, instead of counting the multiples of 3, 5 and 3 and 5 the program has to print a ...
0
votes
1
answer
1k
views
ERROR - Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'DEPRECATED_SERVICE_NAMES' from 'botocore.docs'
I'm supporting a lambda project (python 3.8) and when I run the command "sam local invoke LambdaFunction --event events/get_users.json", it gives the following error
`Invoking main....
0
votes
1
answer
171
views
Type hinting a dictionary with a given set of keys and values
Suppose I have an Enum class in Python:
class MyEnum(Enum):
A = "a"
B = "b"
I have a function that is returning for each of the possible (two in this case) enum values a ...
1
vote
1
answer
358
views
I Get "TypeError: 'NoneType' object is not callable" Error on "@main.result_callback()" When executing run.sh for SimpleNet
I am trying yo run SimpleNet network and when I enter the command bash run.sh on the terminal I see the following output:
Matplotlib created a temporary cache directory at /tmp/matplotlib-ovjj_rt5 ...
2
votes
1
answer
161
views
Take text file and create csv file
I have a larger Python 3 program that processes OCR outputs and some bubble detection and I have it mostly worked out. I have one function that I got off Stack Overflow that works but has a weird side ...
0
votes
2
answers
975
views
FileNotFoundError when re-reading s3 parquet partition that was cached by PyArrow fsspec before partition was altered
The sequence of events to replicate is as such:
read in a s3 parquet partition using pandas.read_parquet (which is pyarrow.dataset under the hood).
add another file into that partition.
read the same ...
1
vote
1
answer
358
views
AWS Lambda Function Not Producing Expected Result
I am working on an AWS Lambda function for an end-to-end data engineering project involving YouTube data analysis. The function is designed to read JSON data from an S3 bucket, process it, and write ...
3
votes
0
answers
378
views
AttributeError: 'ManyToOneRel' object has no attribute 'attname'
I changed a OnetoOnefield in a PostImage model to a ForeignKey and getting the said error.
Here is what is changed :
class PostImage(models.Model):
# post = models.OneToOneField(Post, on_delete=models....
0
votes
1
answer
52
views
Merging DataFrames in Pandas with Common Column, but Different Lengths and Values - Python 3.8.3, Pandas 1.0.5 [duplicate]
I am generating dataframes from hdf5 datasets in a h5td file. These datasets are typically very large and I need to merge them. The general format is as follows:
group1/dataset1
group1/dataset1_Time
...
0
votes
0
answers
114
views
Is there a way to return values using a TaskPool when making a large number of HTTP requests with asyncio/aiohttp?
This question is related to this one: perform-large-numbers-of-http-requests-asyncronously-n-at-a-time
The problem is that I want to make a large amount of requests, about 500.000, each request get a ...
0
votes
1
answer
570
views
Is there a way to call python3.8 code, from python3.11?
I have some code that breaks in python3.11 for some reason, namely paddleocr. I want to integrate it in a program that is otherwise written in python3.11.
Although there is the obvious method of ...
1
vote
0
answers
39
views
Using ConfigParser in Python with INI name in a variable
I have two 'conf' files with content in '[section] name=value' format.
The first conf file has a value that contains the name of a second conf file.
I can use ConfigParser.read() to read the first ...