QuestionId
int64
74.8M
79.8M
UserId
int64
56
29.4M
QuestionTitle
stringlengths
15
150
QuestionBody
stringlengths
40
40.3k
Tags
stringlengths
8
101
CreationDate
stringdate
2022-12-10 09:42:47
2025-11-01 19:08:18
AnswerCount
int64
0
44
UserExpertiseLevel
int64
301
888k
UserDisplayName
stringlengths
3
30
79,715,602
11,415,809
When using scipy.optimize.curve_fit what is the optimal formulation of the function being fitted?
<p>I noticed that the formulation matters when trying to fit a non-linear equation of the form <code>y = a + b * x ** c</code> and I wonder which formulation <strong>in general</strong> results in the best fit?</p> <h2>Formulation 1</h2> <ul> <li><code>y = a + b * x ** c</code></li> <li>needs more than default maximum ...
<python><scipy><curve-fitting><scipy-optimize>
2025-07-26 10:29:03
2
481
3UqU57GnaX
79,715,279
27,596,369
Pyttsx3 not saving MP3
<p>Here is my code:</p> <pre><code> mp3_path = filedialog.asksaveasfile(filetypes=((&quot;MP3 files&quot;, &quot;*.mp3&quot;), (&quot;All files&quot;, &quot;*.*&quot;))) # User prompt to select a path. engine = pyttsx3.init() # A pyttsx3 object engine.se...
<python><tkinter><pyttsx3>
2025-07-25 22:08:17
2
1,512
Aadvik
79,715,255
9,965,155
Python asyncio: AttributeError: 'coroutine' object has no attribute 'state' with RuntimeWarning: coroutine was never awaited
<p>I'm trying to run a basic stateful session using the <code>google.adk</code> library in Python, interacting with a <code>question_answering_agent</code> and <code>InMemorySessionService</code>. I encountered a series of errors related to imports, asynchronous operations, and API key loading.</p> <p>My goal is to suc...
<python><google-agent-development-kit>
2025-07-25 21:22:06
1
2,006
PinkBanter
79,715,248
814,438
RabbitMQ - Consume a Large Volume of Messages from a Queue withou ACK
<p>I would like to read a large volume of messages from a RabbitMQ queue, but negatively acknowledge (NACK) them. Some other consumer will ACK them and do work later.</p> <p>I have 100,000 messages in a queue. The following Python code is my attempt to print information about all messages:</p> <pre class="lang-py prett...
<python><rabbitmq><pika>
2025-07-25 21:05:17
0
1,199
Jacob Quisenberry
79,715,225
5,294,585
Python Flask Class initiating with NoneType despite being passed
<p>I'm working on a flask app and it's been running for a while and I don't often add new users so I don't know exactly when this broke, but recently I tried to add a new user and I'm getting an error when adding a User to the database that appears to be caused by the class not instantiating with the variables set. Her...
<python><flask>
2025-07-25 20:35:01
1
908
David Scott
79,715,189
27,596,369
How to slowly make scrolledtext.ScrolledText text transparent
<hr /> <p>I am making an app where when you stop typing, your text starts to get more transparent until it disappears. How do I do that?</p>
<python><tkinter>
2025-07-25 19:51:29
1
1,512
Aadvik
79,715,164
2,000,640
Wxpython with matplotlib - resize plot
<p>I’m using matplotlib in wxpython, and here is what I’m trying to do…</p> <p>I’d like to define my figure to be a specific (user chosen) size…say 8 inches wide by 6 inches high.</p> <p>Then, I’d like the user to be able to size the window and resize/scale the plot to fit the window, but the underlying figure still be...
<python><matplotlib><wxpython>
2025-07-25 19:21:32
1
2,268
David Hope
79,715,118
27,596,369
Why is Tkinter scrolled text width and height different sizes?
<p>I created a <code>scolledtext.ScrolledText</code> in my application and passed <code>width=50 and height=50</code> but the width was half the height, so I changed width to 100 and it worked. But I was just wondering why it is like that.</p>
<python><tkinter>
2025-07-25 18:16:41
1
1,512
Aadvik
79,715,106
2,058,333
Replicate PIL.Image.show() scaling and normalization
<p>I am curious what the PIL library does value scaling and normalization wise to show me crisp image and why just doing matplotlib on the extracted numpy value looks really bad.</p> <p>Here is my code</p> <pre><code> the_image = Image.open(temp_image_file) sub_image = the_image.crop((520,965,565,1900)) ...
<python><matplotlib><python-imaging-library><ocr>
2025-07-25 18:05:39
1
5,698
El Dude
79,714,981
9,879,534
How to specify one letter's case while ignore other letters' case in a regex?
<p>Say I want to write a regex to match text like &quot;Table 1.1-1 Abcd&quot; / &quot;FIGURE 1: Efg&quot; / &quot;Image 1.1 Hijk lmn&quot; but refuse &quot;Table 1.1: abcd efg&quot;, which means the first letter behind &quot;Table&quot; / &quot;Figure&quot; ... must be uppercase, but &quot;Table&quot; and &quot;TABLE&...
<python><regex>
2025-07-25 15:46:12
1
365
Chuang Men
79,714,931
4,704,065
Fit the rows and column names using pandas.set_option
<p>I am trying to use <strong>pandas.set_option</strong> for my python script to display a table but some how the data does not fill properly in an html page Since the names in some column are bit longer , columns look 1 below another</p> <p>Is it possible to split the entries eg: in &quot;<strong>Log File</strong>&quo...
<python><pandas><dataframe>
2025-07-25 15:05:48
1
321
Kapil
79,714,763
11,246,056
How to display dataframe index when executing a cell in marimo?
<p>If I execute the following toy code in a Jupyter notebook:</p> <pre><code>import pandas as pd pd.DataFrame({&quot;col1&quot;: [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;], &quot;col2&quot;: [&quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;h&quot;]}) </code></pre> <p>The dataframe is displayed wit...
<python><marimo>
2025-07-25 12:59:55
1
13,680
Laurent
79,714,638
14,720,380
How can I use ImportString in Pydantic to get an instance of a class?
<p>I am trying to use an <code>ImportString</code> to get an instance of a given object:</p> <pre class="lang-py prettyprint-override"><code>from __future__ import annotations from pydantic.types import ImportString from pydantic import Field, BaseModel from typing import Annotated, Callable class Foo: &quot;&qu...
<python><pydantic-v2>
2025-07-25 11:14:35
0
6,623
Tom McLean
79,714,594
12,439,683
Check if Python argparse used explicit CLI argument or default value?
<p>I derive some settings from my parser that I latter store on disk to be reloaded again, during the reload I want to overwrite some values but keep the first ones, similar to new default values.</p> <p>I want to have a priority of <code>args2</code> &gt; <code>args1</code> &gt; <code>default</code> values, however I ...
<python><argparse><python-tap>
2025-07-25 10:45:10
1
5,101
Daraan
79,714,515
1,719,931
SPECTER2 similarity performs poorly
<p>I'm trying to compute a measure of semantic similarity between titles of scientific publications using <a href="https://huggingface.co/allenai/specter2" rel="nofollow noreferrer">SPECTER2</a>, but the model performs poorly.</p> <p>Here is my code:</p> <pre class="lang-py prettyprint-override"><code>from transformers...
<python><pytorch><huggingface-transformers><word-embedding><sentence-similarity>
2025-07-25 09:38:07
0
5,202
robertspierre
79,714,499
1,877,600
Unable to Connect to Azurite Container from Custom Engine Container in Integration Tests
<p>I'm currently working on integration tests for my project, which consists of two main components: an application and an engine. Both components are deployed into Azure Container Apps. The engine scales using Azure Storage Queue. The workflow is as follows:</p> <ol> <li>The application sends a request to the Azure qu...
<python><integration-testing><testcontainers><azurite>
2025-07-25 09:25:21
0
597
user1877600
79,714,469
4,662,490
Pytest rootdir differs between local and GitHub Actions (macOS)
<p>I'm developing a Python <a href="https://github.com/DT-Service-Consulting/gtfs_railways" rel="nofollow noreferrer">package</a> called <code>gtfs_railways</code>, and my local setup is working perfectly — but in CI, path resolution breaks and makes my tests fail. Note that, for legacy reasons, I am using Python 3.8.<...
<python><github-actions><pytest>
2025-07-25 08:59:08
1
423
Marco Di Gennaro
79,714,452
4,311,316
False output with datetime week and isocalendar()
<p>I have this GUI with the button &quot;get dates for last week&quot;.</p> <p>I programmed this in 2024, using <code>datetime</code> objects and the <code>isocalendar()</code> method - and the button worked like a charm, returning the dates for Monday (first date of the week) and Sunday (last date of the week)</p> <p>...
<python><datetime>
2025-07-25 08:49:09
2
385
Red
79,714,421
8,964,393
Assign column status retrospectively in pandas
<p>I have created the following pandas dataframe:</p> <pre><code>import pandas as pd import numpy as np ds = {'col1' : [234,321,284,286,287,300,301,303,305,299,288,300,299,287,286,280,279,270,269,301]} df = pd.DataFrame(data=ds) </code></pre> <p>The dataframe looks like this:</p> <pre><code>display(df) col1 0 ...
<python><pandas><dataframe><if-statement><multiple-columns>
2025-07-25 08:24:36
1
1,762
Giampaolo Levorato
79,714,287
219,153
Why is Numba more efficient with 2D vs 1D version of this loop?
<p>I'm using Python 3.12.11 with Numba 0.61.2 on Ubuntu 22.04.5 and AMD Ryzen 7 3800X CPU. This benchmark:</p> <pre><code>import numpy as np, timeit as ti, numba as nb @nb.njit(fastmath=True) def f1d(img, w): fl = np.zeros_like(img) for i in range(w, len(img)-w): p = img[i] fl[i] = max(abs(p-img[i+1]), ab...
<python><for-loop><vectorization><numba>
2025-07-25 06:35:33
2
8,585
Paul Jurczak
79,714,277
4,281,353
FEAST Feature Store - What is event_timestamp in entity_df parameter of FeatureStore.get_historical_features method
<p>What is <code>event_timestamp</code> in <code>entity_df</code> parameter of <code>FeatureStore.get_historical_features</code> method?</p> <p>Are they dummy random timestamp just to create data? And what does <strong>ensure point-in-time correctness</strong> mean?</p> <ul> <li><a href="https://rtd.feast.dev/en/master...
<python><feast>
2025-07-25 06:31:59
0
22,964
mon
79,714,241
13,687,718
Python service memory leaks on Ubuntu at scale
<p>I have a python based service that uses libraries such as requests or curl-cffi to fetch the content of our webpages which we currently are testing for scale.</p> <p>As the expected response is the content of my webpage which might be around 1MB in size per request, I see an increase in the heap memory usage when a ...
<python><linux><ubuntu><memory-leaks>
2025-07-25 05:52:23
0
832
mang4521
79,714,189
11,218,687
How to extend fixture from the base class?
<p>I'm trying to extend a fixture: that means not only overriding, but partially reusing the old one. For example, in the code below the fixture <code>Test.values</code> uses the fixture <code>values</code> and concatenates lists defined in both functions:</p> <pre class="lang-py prettyprint-override"><code>import pyte...
<python><pytest><overloading><fixtures><pytest-fixtures>
2025-07-25 04:29:37
2
6,630
Dmitry Kuzminov
79,714,113
3,361,802
Error while setting a value using Actuator on kuksa
<p>I am using <a href="https://github.com/eclipse-kuksa/kuksa-mock-provider" rel="nofollow noreferrer">https://github.com/eclipse-kuksa/kuksa-mock-provider</a> in my local to try. My kuksa broker is up and running fine.</p> <p>When do GET for a actuator path 'Vehicle.Body.Windshield.Front.Wiping.System.Mode', it works ...
<python><grpc><grpc-python>
2025-07-25 01:45:39
0
339
user12
79,713,886
27,596,369
How to set an image for class that inherits Turtle
<p>What I am trying to do is create a class called <code>Meteor()</code> which inherits from the <code>turtle.Turtle()</code> class. My current code is this:</p> <pre><code>from turtle import Turtle class Meteor(Turtle): def __init__(self, health): Turtle.__init__(self) self.health = health </code...
<python><turtle-graphics>
2025-07-24 19:44:01
2
1,512
Aadvik
79,713,687
1,935,424
Msys2 open a terminal from a python script with given rows and columns
<p>I am using MSYS2 and using a python script invoked from the command line in a bash terminal to open an other terminal with given rows and columns.</p> <p>Here's what I got so far:</p> <pre><code> cmd = 'C:/msys64/msys2_shell.cmd ' \ '-msys2 ' \ '-shell bash ' \ ...
<python><msys2><mintty>
2025-07-24 16:24:20
1
899
JohnA
79,713,572
18,002,913
How to access the base train class in YOLOv11 from the Ultralytics GitHub repository?
<p>I'm currently working on training a custom object detection model using <strong>YOLOv11</strong>, and I'm diving into the Ultralytics GitHub repository to better understand the internal structure of the training process.</p> <p>I’ve noticed that older versions like <strong>YOLOv5</strong> or <strong>YOLOv8</strong> ...
<python><optimization><parameters><ultralytics><yolov11>
2025-07-24 14:52:34
0
1,298
NewPartizal
79,713,450
1,982,032
Why do I get nothing in output with pytesseract?
<p>I have installed language support for <code>chi_sim</code>:</p> <pre class="lang-none prettyprint-override"><code> ls /usr/share/tesseract-ocr/5/tessdata chi_sim.traineddata eng.traineddata pdf.ttf configs osd.traineddata tessconfigs </code></pre> <p>You can try it by downloading <a href="https://www.dr...
<python><ocr><python-tesseract>
2025-07-24 13:33:11
2
355
showkey
79,713,188
8,445,557
Issue on call FastMCP Server using Postman
<p>I have this simple MCP Server:</p> <pre class="lang-py prettyprint-override"><code>from fastmcp import FastMCP, Context mcp = FastMCP(&quot;Demo 🚀&quot;) @mcp.tool def add(a: int, b: int) -&gt; int: &quot;&quot;&quot;Add two numbers&quot;&quot;&quot; return a + b @mcp.tool def hello(ctx: Context): ct...
<python><model-context-protocol>
2025-07-24 10:37:22
2
361
Stefano G.
79,713,113
4,844,184
Streaming the reading of a very large compressed JSON file in Python
<p>I have a very large (too large to hold in RAM) <code>.json.zstd</code> file that I built iteratively with a generator of texts <code>data_chunks</code>. A completely toy example of such generator is:</p> <pre class="lang-json prettyprint-override"><code>[{&quot;text&quot;: &quot;very very&quot;},&quot; very very&quo...
<python><json><streaming><zstd><ijson>
2025-07-24 09:36:53
1
2,566
jeandut
79,712,795
11,085,329
Python 3 changes variable even after if condition fails
<p>I have a kaggle notebook(<a href="https://www.kaggle.com/code/haroonazharkhan/exercise-underfitting-and-overfitting" rel="nofollow noreferrer">link here</a>). The notebook iterates over a list of number(<code>candidate_max_leaf_nodes</code>) and then gets a mae for each number by massing it as a parameter(ignore the...
<python><machine-learning><jupyter-notebook><scope><kaggle>
2025-07-24 04:25:14
1
450
HAK
79,712,728
16,312,980
Why does polars kept killing the python kernel when joining two lazy frames and collecting them?
<p>I have one dataframe: bos_df_3 that has about a 30k+ rows and another, taxon_ranked_only, with 6 million when I tried to join them using:</p> <pre><code>matching_df = ( pl.LazyFrame(bos_df_3) .join( other=taxon_ranked_only, on=[&quot;genericName&quot;, &quot;specificEpithet&quot;, &quot;infraspecificEpithet&...
<python><memory><python-polars><polars>
2025-07-24 02:32:17
1
426
Ryan
79,712,538
199,818
My python project that requires a plugin that I also wrote fails on poetry install because the "version solving failed"
<p>I am using the following versions:</p> <pre><code>Poetry (version 2.1.1) Python 3.13.2 pip 25.0.1 from &lt;correct path to the pip location in venv&gt; </code></pre> <p>I have written an application plugin for poetry. That project has a section in the <code>pyproject.toml</code> file like this:</p> <pre><code>[proje...
<python><python-3.x><pip><python-poetry>
2025-07-23 20:37:32
1
857
Ian Leslie
79,712,396
8,297,745
How to get a billing cycle period between the 26th of the previous month and the 25th of the current month using Python (timezone-aware)?
<h2>The Problem</h2> <p>I'm building a billing system in Django, and I need to calculate the billing period for each invoice.</p> <p>Our business rule is simple:</p> <ul> <li>The billing cycle starts on the <strong>26th of the previous month</strong> at midnight (00:00:00);</li> <li>And ends on the <strong>25th of the ...
<python><django><datetime><timezone><billing>
2025-07-23 18:13:01
1
849
Raul Chiarella
79,712,154
2,137,996
Where should development dependencies go in a post-PEP 735 pyproject.toml?
<p>Much has changed in the world of Python dependency management in the last few years and I am looking for some authority regarding where to specify a few classes of dependency in the <code>pyproject.toml</code> file. For context, I am working on a Python project that includes a native extension module.</p> <p>Here ar...
<python><dependency-management><pyproject.toml>
2025-07-23 15:09:04
0
20,663
Alex Reinking
79,712,006
1,659,527
Python requests library refusing to accept correct verify certificate
<p>The following application performs a basic HTTP GET request against <code>https://google.com</code>, retrieves the peer certificate and saves it in PEM format into a file called <code>cert.pem</code>.</p> <p>After that it attempts the connect to <code>https://google.com</code> again, but this time specifies the save...
<python><python-requests><cryptography>
2025-07-23 13:43:14
0
3,307
jwa
79,711,979
850,781
Moving from matplotlib to pyqtgraph: how to reuse PlotWidgets?
<p>I have a large gui app based on <code>matplotlib</code> which is horribly slow (on windows) so I am trying to re-host it on <code>pyqtgraph</code> (which seems to be <em>much</em> faster).</p> <p>I am facing the following problem: I need to plot <em>very</em> different things (vastly different ranges, axes formattin...
<python><matplotlib><pyqt6><pyqtgraph>
2025-07-23 13:30:46
0
60,468
sds
79,711,862
7,446,528
Parse a CSV translation file that contains "None" as a standalone string
<p>I am working on a large CSV file that contains number IDs for translations followed by entries for different languages. These entries represent localization strings in an application. I was tasked with parsing and making changes to these entries but have encountered an issue when the string &quot;None&quot; as is an...
<python><pandas><dataframe>
2025-07-23 12:14:28
0
1,180
Hadi Farah
79,711,807
72,437
Is It Safe to Use stream() Inside a Firestore Transaction in Python?
<p>While conducting a code review today, multiple AIs advised against using the <code>stream()</code> function within a Firestore transaction in Python.</p> <p>However, I couldn't find any mention of this limitation in the official documentation:</p> <p><a href="https://firebase.google.com/docs/firestore/manage-data/tr...
<python><firebase><google-cloud-firestore>
2025-07-23 11:37:33
1
42,256
Cheok Yan Cheng
79,711,708
736,221
Is it possible to use retries and deadletter queues in Celery?
<p>I have successfully got Celery to put failed tasks onto deadletter queues in RabbitMQ, thanks to this answer <a href="https://stackoverflow.com/a/46128311/736221">https://stackoverflow.com/a/46128311/736221</a> and this article <a href="https://medium.com/@hengfeng/how-to-create-a-dead-letter-queue-in-celery-rabbitm...
<python><rabbitmq><celery>
2025-07-23 10:23:43
1
687
grahamlyons
79,711,502
12,415,855
WebGL is disabled error when opening bing maps with python selenium?
<p>i try to open bing maps using python selenium with this code:</p> <pre><code>import os, sys from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service options = Options() options.add_argument(&quot;start-maximized&quot;) options.add_a...
<python><selenium-webdriver><webgl>
2025-07-23 07:59:23
1
1,515
Rapid1898
79,711,017
27,596,369
How to make turtle detect which side it collided on
<p>Here is a MRE of my code:</p> <pre><code>from turtle import Turtle, Screen import time import random # --------------- GLOBAL VARIABLES -------------------- speed_x = 20 speed_y = 20 bricks = [] def check_collision(): global speed_x, speed_y, bricks if ball.xcor() &gt; (window.window_width() / 2) - 20 or...
<python><turtle-graphics>
2025-07-22 20:30:29
2
1,512
Aadvik
79,710,997
4,976,543
How to regex match all strings except when the pattern occurs at a specific position?
<p>I have a problem that would benefit greatly if I can include all matches of a pattern that do not occur at one specific index in a string. For example, if I want to match &quot;ABC&quot;, except when it occurs in the 4th position of the string, I would need the following results:</p> <ul> <li><strong>ABC</strong>DE...
<python><regex>
2025-07-22 20:09:51
4
712
Branden Keck
79,710,989
27,596,369
Turtle not detecting key presses in Python
<p>Here is a HUGELY simplified version of my code:</p> <pre><code>from turtle import Turtle, Screen import time speed_x = 20 speed_y = 29 def move_right(): print('exectuted') def game_loop(): ball.goto(ball.xcor() + speed_x, ball.ycor() + speed_y) window.update() window.ontimer(game_loop, 1) windo...
<python><turtle-graphics><python-turtle>
2025-07-22 19:58:51
1
1,512
Aadvik
79,710,792
27,596,369
Turtle pauses when I try to turn it
<p>Here is my code:</p> <pre><code>from turtle import Turtle, Screen import time import random def check_wall_collision(): if ball.xcor() &gt; (window.window_width() / 2) - 20 or ball.xcor() &lt; -(window.window_width() / 2) + 20: ball.left(180) elif ball.ycor() &gt; (window.window_height() / 2) - 20 o...
<python><turtle-graphics><python-turtle>
2025-07-22 16:28:44
1
1,512
Aadvik
79,710,699
850,781
QLabel css "text-align: center" is ignored
<p>Contrary to <a href="https://doc.qt.io/qt-6/stylesheet-reference.html" rel="nofollow noreferrer">the spec</a>, CSS setting <code>text-align: center</code> is ignored by <code>QLabel</code> (other settings like <code>font-size</code> and <code>color</code> are respected):</p> <pre><code>from PyQt6.QtWidgets import QA...
<python><css><qt><pyqt><text-align>
2025-07-22 15:11:30
0
60,468
sds
79,710,652
2,311,202
Delta/Difference Histogram
<p>Minimum working example:</p> <pre><code>import pandas as pd import plotly.graph_objects as go # Example data data = { &quot;data-a&quot;: [10, 15, 10, 20, 25, 30, 15, 10, 20, 25], &quot;data-b&quot;: [12, 18, 14, 22, 28, 35, 17, 13, 21, 27] } df = pd.DataFrame(data) # Create the figure fig = go.Figure() fi...
<python><plotly><histogram>
2025-07-22 14:38:13
2
506
Pietair
79,710,580
8,704,639
Numpy Bug in computing business days?
<p>I am trying to compute business days using Numpy.</p> <p>I how ever found an inconsistency.</p> <pre><code>import numpy as np # Count from 1st Jan 2023 to 31st Jan 2023 print(&quot;Jan: {0}&quot;.format(np.busday_count('2023-01-01', '2023-01-31'))) # Returns 21 days # To get actual business days do 21 + 1 = 22, si...
<python><numpy><datetime>
2025-07-22 13:45:21
1
583
M4X_
79,710,168
4,702,527
Human in the loop to work in both Langgraph studio and CLI based
<p>I have a LangGraph agent from a Python shell script, and I expose it as a Typer command to be executed from the command line. Everything works fine. But now I want to add a human in the loop as one node. The problem is if I add input(&quot;Enter yes or no&quot;), then it works in CLI but not in LangGraph Studio. And...
<python><command-line-interface><langgraph><typer>
2025-07-22 08:38:01
2
471
Sowmya
79,709,834
2,063,329
Streamlit Cloud fails to clone public GitHub repo – “Failed to download sources” error despite correct config
<p>I'm deploying a Streamlit app to Streamlit Cloud from a public GitHub repo named MonteSimLite. Everything in the repository appears healthy:</p> <ul> <li><p>Repo is public</p> </li> <li><p>Branch is main</p> </li> <li><p>Entry point is app.py, located at the root</p> </li> <li><p>Python version set to 3.11</p> </li>...
<python><git><github><streamlit>
2025-07-22 03:22:12
1
457
user2063329
79,709,674
395,255
JMESPath filter nested objects based on exact match of the value of an attribute
<p>Is it possible to get a JMESPath expression to return <code>groups</code> and <code>group_elements</code> based on the match on <code>group_name</code>?</p> <p>I haven't even been able to get <code>group_elements</code> so far so getting two objects returned is beyond me.</p> <p>This is what I have tried so far:</p>...
<python><jmespath>
2025-07-21 22:22:44
1
12,380
Asdfg
79,709,532
27,596,369
How to delete last word of Tkinter ScrolledText Widget
<p>I have a <code>scrolledtext.ScrolledText</code> widget which has some text in it, what I want to do is delete the last word of the widget. I tried searching it up on the internet and found nothing.</p> <p>If sample code is needed I can give it.</p> <p>I have tried to find the index of the final word since I do know ...
<python><tkinter>
2025-07-21 19:09:26
1
1,512
Aadvik
79,709,521
3,577,105
python asyncio: allow user to choose fire-and-forget vs blocking-group-of-functions
<p>I'd like to send an http request, and then operate on its response:</p> <pre><code>import requests s=requests.Session() .... (session setup...) .... (url and params setup...) .... r=s.get(url,params=params) print('response json:'+str(r.json())) </code></pre> <p>In that case, the request should be blocking, so that...
<python><multithreading><python-requests><python-asyncio>
2025-07-21 18:50:04
1
904
Tom Grundy
79,709,488
459,745
click.option with deprecated=str failed with unexpected keyword argument
<p>Here is short sample, which uses <code>click==8.1.7</code></p> <pre><code># main.py import click @click.command @click.option( &quot;--disable-all&quot;, is_flag=True, default=False, deprecated=&quot;Please use --disable-all-features&quot;, ) @click.option(&quot;--disable-all-features&quot;, is_fla...
<python><python-click>
2025-07-21 18:18:36
1
41,381
Hai Vu
79,709,465
12,311,820
Django Celery with prefork workers breaks OpenTelemetry metrics
<p>I have a Django application I wanted to instrument with OpenTelemetry for traces and metrics. I created an <code>otel_config.py</code> file next to my <code>manage.py</code> with this content:</p> <pre class="lang-py prettyprint-override"><code># resources def get_default_service_instance_id(): try: host...
<python><django><celery><open-telemetry>
2025-07-21 17:56:16
1
357
Ashkan Khademian
79,709,374
281,965
Using polymorphic_identity and inheritance is raising a warning
<p>I have the following code, where I need to inherit <code>GroupAB</code> from <code>GroupA</code> because I want to use its functions vs copy-paste them again. since I can't use multiple values for <code>polymorphic_identity=[&quot;GroupA&quot;, &quot;GroupAB&quot;]</code> I tried using the below code yet it resulted...
<python><sqlalchemy>
2025-07-21 16:35:09
1
8,181
Ricky Levi
79,709,356
11,829,002
Codecov failing, and I don't understand why (and how fix this)
<p>I have added a CI using Codecov to ensure that code is sufficiently covered when PR are done in my code.</p> <p>But <a href="https://github.com/thomas-saigre/tikzplotly/runs/46363182837" rel="nofollow noreferrer">the job</a> is still failing after the modifications I made. Here is the <a href="https://app.codecov.io...
<python><continuous-integration><code-coverage><codecov>
2025-07-21 16:23:50
0
398
Thomas
79,709,226
6,461,882
Getting some columns as raw data while others converted to pandas types
<p>Is there a way in KDB/pykx to get only some columns as raw data while get others converted to pandas types?</p> <p>In the example below, I want to be able to do what is shown in the last line (for variable <code>d3</code>), i.e. only get some columns as raw data:</p> <pre><code>import pykx as kx q = kx.SyncQConnecti...
<python><pandas><kdb+><raw-data><pykx>
2025-07-21 14:43:26
1
2,855
S.V
79,709,216
13,392,257
Can't find element by XPATH playwright
<p>I am trying to get all search results (URLs) from <a href="https://docs.vgd.ru/search/?v=1" rel="nofollow noreferrer">https://docs.vgd.ru/search/?v=1</a>. I am using the xpath <code>//a[@class='resultsMain']</code> to find them. The xpath is valid.</p> <p><a href="https://i.sstatic.net/ilSe0cj8.png" rel="nofollow no...
<python><playwright><playwright-python>
2025-07-21 14:28:52
1
1,708
mascai
79,709,133
9,112,151
Problem with multiple Query in view of FastAPI application endpoint
<p>I'm trying to develop filtering/ordering/pagination functionality for FastAPI applications. For now I'm facing difficulty with separating filtering and sorting. The code below generates undesirable swagger:</p> <pre class="lang-py prettyprint-override"><code>from fastapi import FastAPI, Query from pydantic import Ba...
<python><postgresql><sqlalchemy><fastapi><pydantic>
2025-07-21 13:21:51
1
1,019
Альберт Александров
79,708,948
2,950,593
Tensorflow Graph is finalized and cannot be modified
<p>this is my code:</p> <pre><code>vocals_path = &quot;output/song.wav&quot; audio_path = vocals_path from inaSpeechSegmenter import Segmenter import tensorflow as tf # Initialize the segmenter seg = Segmenter() # Analyze the audio file segments = seg(vocals_path) # Print the segments for segment in segments: pr...
<python><tensorflow>
2025-07-21 10:43:33
4
9,627
user2950593
79,708,570
10,844,937
Why httpx timeout not working with stream response
<p>I use <code>httpx</code> to make request to my LLM. Here is the code.</p> <pre><code>import httpx import logging import json from httpx import TimeoutException try: content = '' logging.info(f&quot;request payload:{payload}&quot;) async with httpx.AsyncClient(timeout=LLM_TIMEOUT) as client: async w...
<python><python-requests><httpx>
2025-07-21 05:15:15
1
783
haojie
79,708,291
2,961,927
How to use Polars copy-on-write principle?
<p>I come from C++ and R world and just started using Polars. This is a great library. I want to confirm my understanding of its copy-on-write principle:</p> <pre><code>import polars as pl x = pl.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]}) y = x # Here, y is semantically a copy of x and # users shall treat y as a cop...
<python><dataframe><python-polars><polars>
2025-07-20 18:47:43
1
1,790
user2961927
79,708,270
3,079,439
Adding EarlyStopping() to transformers Trainer() error
<p>I'm using this code for fine-tuning a LoRA model:</p> <pre><code>bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type=&quot;nf4&quot;, ) model = AutoModelForCausalLM.from_pretrained( &quot;tiiuae/falco...
<python><huggingface-transformers><large-language-model>
2025-07-20 18:20:20
0
3,158
Keithx
79,708,131
6,751,456
django-import-export id auto generated by the package during insert?
<p>I'm using <code>django-import-export</code> and trying to work it with multi-thread concurrency.</p> <p>I tried logging the sql queries and notice that <code>INSERT</code> query has <code>id</code> values generated as well.</p> <p>*EDIT: First there's a <code>INSERT</code> without <code>id</code>: There's no <code>i...
<python><django><django-models><django-import-export>
2025-07-20 15:23:09
0
4,161
Azima
79,707,949
7,483,211
How to type-annotate write when subclassing io.RawIOBase, getting "Liskov substitution principle" violation
<p>I want to type-annotate the <code>write</code> in a class that subclasses <code>io.RawIOBase</code>.</p> <p>I'm struggling to get anything other than <code>Any</code> to type check, which is frustrating, because I should be able to use a much more specific type here.</p> <p>The following doesn't type check unfortuna...
<python><python-typing><mypy><liskov-substitution-principle>
2025-07-20 11:02:48
1
10,272
Cornelius Roemer
79,707,880
694,162
Python type-annotation for getitem
<p>I'm implementing a custom class and want to provide type hints for item access (e.g. <code>obj[key]</code>) so that</p> <ul> <li>Pyright/Pylance/VSCode suggests allowed item keys,</li> <li>Pyright/Pylance/VSCode suggests correct methods on the return values, and</li> <li>MyPy performs type checks when the returned v...
<python><dataframe><python-typing>
2025-07-20 09:05:54
0
5,188
sauerburger
79,707,696
25,261,014
How does one read from stdin with a timeout in python?
<p>I'm trying to read from stdin and get <code>None</code> (or some other defined value) should the user not input any text after a predefined timeout. However, when I tried the below code, the script just hung indefinitely at the <code>Enter some text:</code> point and does not time out at 5 seconds, as it should.</p>...
<python><stdin>
2025-07-20 03:40:28
2
362
DeepThought42
79,707,651
5,477,662
Is there a way to specifiy a portable chrome version executable in seleniumbase in python 3
<p>Nothing needed sorry for thepost</p>
<python><python-3.x><seleniumbase>
2025-07-20 01:40:52
2
497
R.Merritt
79,707,650
3,508,551
Sage Differentiation Taking Too Long to Compute
<p>Let <code>U, V</code> both be independent uniform random variables from <code>[0, 1]</code>. I am interested in the function <code>F(x, y) = Pr[2/3 U - 2/3 &lt;= x, 2/3 V - 2/3 &lt;= y]</code> and its derivative. I wrote the following Sage code to calculate it, but it's taking very long (more than 10 minutes and no ...
<python><sage>
2025-07-20 01:38:52
1
2,319
AspiringMat
79,707,645
219,153
Is there a simpler way to select 2D vectors bounded by a box from a NumPy array?
<p>This Python script:</p> <pre><code>import numpy as np a = np.arange(12).reshape(6, 2) inf = np.array([2, 2]) sup = np.array([9, 9]) b = (inf &lt; a) &amp; (a &lt; sup) r = a[b[:, 0] &amp; b[:, 1]] </code></pre> <p>creates a subarray <code>r</code>:</p> <pre><code>[[4 5] [6 7]] </code></pre> <p>of array <code>a</co...
<python><arrays><numpy>
2025-07-20 01:16:03
1
8,585
Paul Jurczak
79,707,467
4,118,781
Python asyncio/Telethon script suddenly stopped working after VSCode restart (Python 3.9.6 on macOS 12.7.6)
<p>I have a Python script using asyncio (for Telethon) and until recently, it was running just fine in a Terminal inside VSCode.</p> <p>However, an extension install prompted a VSCode restart and now I can't get my code to run anymore, even though the code files themselves haven't changed.</p> <p>It seems that Telethon...
<python><python-3.x><macos><exception><runtime-error>
2025-07-19 18:05:20
1
1,495
Sora.
79,707,458
27,596,369
Is Pillow ImageDraw.Draw.draw and Tkinter units the same?
<p>I have a program which writes text based on the size of the image. If the size is 900x900 (tkinter units) then it will write text on 300x300, 300x600, 600x300 and 600x600, but when I try to write that, it only writes on the centre.</p> <pre><code>global draw, img_tk draw = ImageDraw.Draw(img) font = ImageFon...
<python><tkinter><python-imaging-library>
2025-07-19 17:46:33
1
1,512
Aadvik
79,707,091
2,446,374
Getting two titles in pywebview on macOS
<p>I'm using <a href="https://pywebview.flowrl.com/" rel="nofollow noreferrer"><code>pywebview</code></a> to display a web page on a Mac - and for some reason I am getting two titles:</p> <p><a href="https://i.sstatic.net/nuZWkpwP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nuZWkpwP.png" alt="Two tit...
<python><macos><pywebview>
2025-07-19 08:45:47
2
3,724
Darren Oakey
79,706,845
2,446,374
How do I cleanly stop a sanic server without getting errors related to websocket closing?
<p>I have a python sanic website - I'm using pywebview to display it - when I close the pywebview window, I have a watcher which is doing an &quot;app.stop&quot;</p> <p>that works beautifully except I always get this error:</p> <pre><code>Srv 0 10:21:39 ERROR: Error closing websocket connection Traceback (most recent ...
<python><sanic>
2025-07-19 00:32:10
0
3,724
Darren Oakey
79,706,727
10,034,073
In what order do model_validators run in Pydantic?
<p>The Pydantic documentation explicitly <a href="https://docs.pydantic.dev/latest/concepts/validators/#ordering-of-validators" rel="nofollow noreferrer">describes the order of <code>field validators</code></a>, but what about <a href="https://docs.pydantic.dev/latest/concepts/validators/#model-validators" rel="nofollo...
<python><pydantic><pydantic-v2>
2025-07-18 20:43:36
0
444
kviLL
79,706,606
27,596,369
Tkinter widget formatting problems
<p>This is my code:</p> <pre><code>from tkinter import filedialog, ttk from tkinter import * from PIL import Image, ImageTk import numpy as np ########## GLOBAL VARIABLES ######## img_tk = None ####################### BACKEND ################################ # Upload Image Button def upload_image(): global img...
<python><tkinter>
2025-07-18 18:46:33
1
1,512
Aadvik
79,706,522
14,824,108
HDF5 Write Performance Degrades Over Time When Converting from LMDB (~3.7M entries)
<p>I’m experiencing significant slow-downs when converting data from LMDB to HDF5 format. While the conversion starts off quickly, performance degrades substantially partway through the process.</p> <p>Specifically, my dataset contains around 3.7 million entries, and the first ~1.5 million entries are processed quite f...
<python><hdf5><lmdb>
2025-07-18 17:11:25
0
676
James Arten
79,706,486
27,596,369
Is there a way for empty tkinter frame objects to take up space?
<p>I have an app which you can upload a picture into an image label object, but until I uploaded the picture, the image label just didn't take up space. So I put the image in a frame, but it still didn't take up space until I uploaded the image. Is there any way around this?</p> <p>Here is my code:</p> <pre><code>from ...
<python><tkinter>
2025-07-18 16:31:22
1
1,512
Aadvik
79,706,357
4,504,711
How to concurrently remove lines from a file in Python?
<p>I have a cluster of compute nodes, each node with many CPUs. I want them to execute commands located in a file, one command per line. The drive where the command file is located is mounted on all compute nodes.</p> <p>The execution times of these commands vary and to improve load balancing, I am planning to launch a...
<python><locking><cluster-computing><python-multiprocessing>
2025-07-18 14:44:22
1
2,842
Botond
79,706,173
6,805,396
Rotate a label in Plotly Treemap with JavaScript
<p>Sometimes there are narrow bricks on treemaps. Plotly decreases the font size of such labels, so you cannot read them. But another way is making these labels horizontal. As far as I understood the only way to rotate labels in Plotly is using JavaScript. I'm new at it, please help to understand how to select some par...
<javascript><python><plotly><treemap><plotly.js>
2025-07-18 12:31:44
1
609
Vlad
79,706,145
11,232,091
Align bars on different axes on top on each other in matplotlib
<p>I have a df and I am trying to create horizontal bar charts. Currently, I have the code like below.</p> <pre><code> import pandas as pd import matplotlib.pyplot as plt data = {'Name': [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;,'E'], 'Todo': [4, 5, 6, 7, 3], 'Done': [6, 2, 6, 8, 6], ...
<python><matplotlib>
2025-07-18 12:05:21
1
8,117
moys
79,706,085
6,385,767
How to efficiently find shortest and longest paths between node types in Dgraph?
<p>I'm trying to find the <strong>shortest</strong> and <strong>longest</strong> path between two node types across the entire graph in <strong>Dgraph</strong>, similar to how it's done using <strong>APOC</strong> in <strong>Neo4j</strong>.</p> <p>In <strong>Neo4j</strong>, I can use a single query like this:</p> <pre ...
<python><graph-theory><dql><dgraph>
2025-07-18 11:07:17
1
642
Ravindra Gupta
79,706,023
16,389,095
Flet app for Supabase account management: unable to reset password for already registered email
<p>I developed a simple authentication UI (login, registration, and password reset) for a Flet app using Supabase as the backend for user management. The app entry point is the main function which sets up the Supabase client, creates page/view instances, and configures routing.</p> <pre><code>def main(page: ft.Page): ...
<python><supabase><flet>
2025-07-18 10:12:00
1
421
eljamba
79,705,864
6,074,182
How is import os.path possible?
<p>Since <code>os</code> is a module instead of a package, <code>import os.path</code> should fail. For comparison:</p> <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; import os.sys Traceback (most recent call last): File &quot;&lt;python-input-0&gt;&quot;, line 1, in &lt;module&gt; import os.sys M...
<python><python-import><python-internals><os.path>
2025-07-18 08:00:12
0
2,445
Aemyl
79,705,839
2,265,497
Why python prometheus client collectors create metric object every time when collect method is invoked
<p><a href="https://github.com/prometheus/client_python/blob/master/prometheus_client/gc_collector.py" rel="nofollow noreferrer">https://github.com/prometheus/client_python/blob/master/prometheus_client/gc_collector.py</a></p> <pre><code>import gc import platform from typing import Iterable from .metrics_core import C...
<python><prometheus><monitoring>
2025-07-18 07:26:58
1
2,057
slesh
79,705,666
14,373,886
MCPToolConversionError: Failed to get tools from MCP server: 404
<p>I am using python_a2a version 0.5.9, I am trying to use to_langchain_tool from python_a2a.langchain package but I am getting following error while trying to convert a MCP Server to langchain tool</p> <p>code:</p> <pre><code>from python_a2a.langchain import to_langchain_tool add = to_langchain_tool(&quot;http://loc...
<python><langchain><model-context-protocol>
2025-07-18 04:09:55
1
540
JayantSeth
79,705,629
14,373,886
cannot import name 'LangChainBridge' from 'python_a2a.langchain'
<p>I am using python_a2a version 0.5.9 and I am trying to use integration of langchain with python_a2a but I am unable to import ToolServer, LangChainBridge or even AgentFlow</p> <p>I am referring to this document of Python A2A: <a href="https://python-a2a.readthedocs.io/en/latest/guides/langchain.html" rel="nofollow n...
<python><langchain><model-context-protocol>
2025-07-18 03:07:15
2
540
JayantSeth
79,705,542
27,596,369
Tkinter image label object is not going to the desired spot
<p>I have this code with an upload image button and an image label.</p> <pre><code>import tkinter from tkinter import filedialog, Label, Button from PIL import Image, ImageTk # Functions def upload_image(): file_path = filedialog.askopenfilename() if file_path: img = Image.open(file_path) im...
<python><user-interface><tkinter>
2025-07-18 00:48:49
0
1,512
Aadvik
79,705,527
11,628,437
Why does `np.random.default_rng()` prevent seed change compared to `numpy.random.seed`?
<p>I recently learned about the downsides of using <code>numpy.random.seed(seed)</code>. Some internal file can modify the seed.I read an online <a href="https://builtin.com/data-science/numpy-random-seed" rel="nofollow noreferrer">article</a> that suggested I use <code>np.random.default_rng()</code>. But I am not sure...
<python><python-3.x><numpy>
2025-07-18 00:11:09
2
1,851
desert_ranger
79,705,516
6,480,859
WithPlotly's python fig.to_html() function, don't encode numbers as binary
<ul> <li>Python: 3.12.11</li> <li>Plotly: 6.0.1</li> <li>Pandas: 2.2.3</li> <li>Numpy: 2.3.1</li> </ul> <p>When Plotly's Python library exports figures to HTML, it sometimes converts data to binary, which browsers aren't rendering correctly. I can't seem to find any option that forces Plotly to export the data as plain...
<python><html><plotly><plotly-express>
2025-07-17 23:48:35
1
375
relizt
79,705,236
388,520
How do I control the size of margins around a cartopy map projection?
<p>I'm trying to plot a bunch of data on a map of the sky in various projections, using matplotlib + cartopy, and the margins around the maps are always too large and none of the controls I can find seem to help. Example (annotations added after rendering):</p> <p><a href="https://i.sstatic.net/Q9rXdSnZ.png" rel="nofo...
<python><matplotlib><cartopy>
2025-07-17 17:54:30
2
142,389
zwol
79,705,222
16,563,251
Use importlib.resources for files inside the top level parent module
<p>I want to load a file from my python module using <a href="https://docs.python.org/3/library/importlib.resources.html" rel="nofollow noreferrer"><code>importlib.resources</code></a> (see also <a href="https://stackoverflow.com/questions/6028000/how-to-read-a-static-file-from-inside-a-python-package">this question</a...
<python><python-import><python-importlib>
2025-07-17 17:45:03
1
573
502E532E
79,704,941
442,650
Is it possible to type a subclass that only implements a single overload variant?
<p>I am trying to add typing to a legacy project that involves a Superclass and Subclasses that only implement specific variants; I am not sure if this is possible.</p> <p>Classes expose the same general interface - the API method names are the same, but the input/output might be string based for one and int for anothe...
<python><python-typing>
2025-07-17 14:08:07
1
15,770
Jonathan Vanasco
79,704,784
4,889,002
R: How to properly install and use the rgee package?
<p>I first created an account and a project with Google Earth Engine.</p> <p>Then I installed and loaded the <code>rgee</code> package:</p> <pre><code>install.packages(&quot;rgee&quot;) library(rgee) </code></pre> <p>I checked if python is installed:</p> <pre><code>&gt; reticulate::py_available() [1] FALSE </code></pre...
<python><r><google-earth-engine><rgee>
2025-07-17 12:12:37
2
811
Saïd Maanan
79,704,608
5,931,672
Write AEM files with OREKIT
<p>I am new to orekit and without a lot of knowledge about space physics. I am using orekit jpype to create an AEM file. No matter what I try, I get errors of the same format, something like:</p> <pre class="lang-bash prettyprint-override"><code>in write_aem writer.writeMessage(kvn_gen, aem) org.orekit.errors.Oreki...
<python><jpype><orekit>
2025-07-17 09:42:50
1
4,192
J Agustin Barrachina
79,704,338
4,141,279
Tensorflow dataset running out of data durin training
<p>I'm creating a dataset from a csv file containing path-names to image locations and mask-locations (<code>xtr</code> and <code>ytr</code>). Initially, the csv contains approx. 1000 elements. Each image is loaded from cloud space and then split using flat_map into 4 or 8 images depending on the height of the image. S...
<python><tensorflow><tensorflow-datasets>
2025-07-17 05:53:33
3
1,597
RaJa
79,704,151
588,308
Cannot find settings module in mod_wsgi (Apache2 on Ubuntu with django)
<p>I am serving a Python app using Django through an Apache2 server. I have the wsgi.py file in a directory</p> <pre><code>home/peter/django-apps/anaaccess/anaaccess/ana_access/wsgi.py </code></pre> <p>I have a venv in home/peter/django-apps/anaaccess/anaaccess/myenv into which I have installed mod_wsgi and django, etc...
<python><django><apache2><mod-wsgi>
2025-07-17 00:14:35
0
337
peter
79,703,959
880,783
Why does the Python REPL behave differently in VS Code's vs native cmd.exe?
<p>I am running the same <code>python.exe</code>, from the same working directory, in VS Code's terminal running <code>cmd.exe</code>, and in Windows Terminal running <code>cmd.exe</code>. For some reason, these two behave differently.</p> <p>In fact, one recognizes <code>exit</code> while the other does not, insisting...
<python><terminal><exit><read-eval-print-loop><parentheses>
2025-07-16 19:51:59
1
6,279
bers
79,703,817
9,884,998
Unfolding a cartesian binned dataset into polar coordinates
<p>I have a dataset of binned events, corresponding to a cartesian coordinate set</p> <pre><code>[[ 0. 0. 0. 0. 0. 0. 2. 5. 2. 3. 3. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 4. 10. 9. 7. 10. 6. 6. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 9. 12. 10. 11. 14. 13. 11. 12. 6. 0. 0. 0. 0. 0....
<python><numpy><matplotlib><linear-algebra>
2025-07-16 17:41:33
3
529
David K.