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,684,031 | 1,779,973 | How can I detect all missing packages at once when installing from a private PyPI index? | <p>I'm working in a Python project that uses a private Artifactory PyPI index. When I run:</p>
<pre class="lang-bash prettyprint-override"><code>pip install -e ".[dev]" \
--index-url https://<my-artifactory>/artifactory/api/pypi/pypi-local/simple \
--extra-index-url https://<my-artifactory>/ar... | <python><pip><pypi> | 2025-06-29 20:28:17 | 1 | 536 | Ido |
79,683,722 | 5,312,606 | How to rebuild c++ extension when using pyproject.toml | <p>I have a few C++ extensions for a python library.</p>
<p>Previously, this library was shipped using <code>setup.py</code> and one could recompile via
<code>python setup.py build_ext --inplace</code> if only the C++ files changed.</p>
<p>Since I had to change the build system to manage more complex dependencies, I sw... | <python><c++><pybind11><pyproject.toml> | 2025-06-29 12:03:42 | 1 | 1,897 | mcocdawc |
79,683,580 | 22,780,476 | ModuleNotFoundError: No module named 'autogen_core' when importing FunctionTool and Tool | <pre><code>Traceback (most recent call last):
File "C:\Work\code_agent.py", line 2, in <module>
from autogen_core.tools import FunctionTool, Tool
ModuleNotFoundError: No module named 'autogen_core'
</code></pre>
<p>What is the correct way to import FunctionTool and Tool?</p>
<p>I have pyautogen==0... | <python> | 2025-06-29 08:04:27 | 1 | 402 | amrita yadav |
79,683,496 | 17,275,378 | polars.read_database() Fails with Enum Type when Using schema_overrides | <p>I have a database table with an Enum column. My application does transforms with <code>polars</code>, so I'm reading with the <code>pl.read_database()</code> method. However reading the table when <code>schema_overrides</code> is supplied fails.</p>
<h4>Minimum Reproducible Example</h4>
<h5>Imports</h5>
<pre><code>#... | <python><enums><python-polars><cockroachdb><sqlmodel> | 2025-06-29 04:31:21 | 0 | 326 | eldrly |
79,683,433 | 9,015,675 | Python Bluetooth advertising fails when I include any manufacturing data | <p>I'm using a Raspberry Pi 3 with a fresh install of Raspberry Pi OS Lite 32-bit. I have a Bluetooth Dongle that supports Bluetooth Low Energy. I'm running Python 3.11.2.</p>
<p>I am attempting to broadcast a Bluetooth advertisement. When I run my Python script I can see the advertisement using the LightBlue or nRF Co... | <python><bluetooth><bluetooth-lowenergy> | 2025-06-29 01:47:56 | 1 | 503 | Adam |
79,683,425 | 27,596,369 | df.head() is returning ValueError: Per-column arrays must each be 1-dimensional | <p>Here is my code:</p>
<pre><code>set_theme_count = sets_df["theme_id"].value_counts()[:-5]
</code></pre>
<p>Result: <a href="https://i.sstatic.net/rUIm7vvk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rUIm7vvk.png" alt="DataFrame Head" /></a></p>
<p>Now, I want to rename the columns so I c... | <python><pandas><dataframe> | 2025-06-29 01:22:38 | 1 | 1,512 | Aadvik |
79,683,236 | 6,043,170 | python can't connect, but openssl can | <p>I am trying to connect to a legacy (windows server 2008R2) server using python / winrm. I am seeing an issue where openssl can establish the ssl socket cleanly, but python and winrm can't. I am using python3.12 on ubuntu 24.04 (noble)</p>
<p>here is the python code:</p>
<pre class="lang-py prettyprint-override"><c... | <python><ssl><openssl> | 2025-06-28 18:20:52 | 1 | 16,057 | 2ps |
79,683,201 | 2,534,938 | Using Tkinter in Python, How Can I Autosize a Canvas to its Parent Frame | <p>I'm trying to build a Tkinter form in Python that has three "frames": a narrow frame across the top (for a title), a thin frame down the left (for buttons), and a main frame (to show content). The left frame will have buttons, and the top and main frames will have canvases that can be drawn on. I'd like ... | <python><tkinter><canvas><grid> | 2025-06-28 17:47:07 | 2 | 733 | Boulder Keith |
79,683,049 | 5,568,409 | How to convert annotation in bold text? | <p>This is a reproducible program displaying an annotated line:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
fig, ax = plt.subplots(figsize=(6, 4))
point1 = [0, 1]
point2 = [np.sqrt(2), 0]
x_values = [point1[0], point2[0]]
y_values = [point1[1], point2[1]... | <python><matplotlib> | 2025-06-28 13:45:24 | 1 | 1,216 | Andrew |
79,683,006 | 7,517,392 | Transform Dataframe with Duplicate Date Entries | <p>I have a dataframe that looks like this (so there is no unique Index):</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>Data</th>
<th>Product</th>
</tr>
</thead>
<tbody>
<tr>
<td>1/1/25</td>
<td>1</td>
<td>A</td>
</tr>
<tr>
<td>2/1/25</td>
<td>2</td>
<td>A</td>
</tr>
<tr>
<td... | <python><pandas><dataframe> | 2025-06-28 12:40:36 | 2 | 361 | Stanford Wong |
79,682,984 | 5,118,421 | rsrync make folder read-only for venv despite 777 and chown | <p><strong>Steps</strong>:</p>
<ol>
<li><p>Run <code>rscyn</code> on remote ssh server with folder with venv python, lets assume <code>.venv</code>.</p>
</li>
<li><p>Run <code>source .venv/bin/python3</code> on the either source or destination folder, lets assume *destination folder.</p>
</li>
<li><p>Create empyt pytho... | <python><python-3.x><linux><ubuntu><rsync> | 2025-06-28 12:10:01 | 1 | 1,407 | Irina |
79,682,876 | 5,568,409 | How to create same ticks and labels on both axes? | <p>I have to create a plot on which <code>ticks</code> and <code>labels</code> are specifically defined; an example of reproducible plot is given below:</p>
<pre><code>import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('seaborn-v0_8')
fig, ax = plt.subplots(figsize=(4, 4))
ticks = [0.00, 0.25, 0.50, ... | <python><python-3.x><xticks><yticks> | 2025-06-28 09:28:34 | 2 | 1,216 | Andrew |
79,682,838 | 595,305 | Is there any way to obtain a listing of enum names and values in a typedef for QFlags? | <p>As such I (questioner) am no longer looking for an answer but I am not sure on what grounds to recommend closing. It could possibly be helpful to someone.</p>
<p>Here's an example of what I mean (based on <a href="https://doc.qt.io/archives/qt-5.15/qt.html#Orientation-enum" rel="nofollow noreferrer">Qt5 documentatio... | <python><enums><pyqt><pyqt5><pyqt6> | 2025-06-28 08:24:09 | 1 | 16,076 | mike rodent |
79,682,339 | 5,568,409 | How to introduce seed in np.random.random? | <p>I need to create a number of points in a square [0,1]x[0,1].</p>
<p>To obtain an array of coordinates, I used:</p>
<pre><code>N_fixed_points = 10
selection = np.random.random((N_fixed_points,2))
</code></pre>
<p>which gives me a proper result.</p>
<p>But I would like to reproduce the same selection output and I know... | <python><python-3.x><random><seed> | 2025-06-27 18:06:34 | 1 | 1,216 | Andrew |
79,682,250 | 2,939,369 | is there a way to assign a numpy array into pandas without a copy? | <p>I'm in a performance critical field, where we store our results in pandas dataframes - issue is we are doing most of computations in numpy and then assigning to pd later - but this forces a copy on assign:
<code>df['col'] = arr # this will create a copy</code></p>
<p>My quesiton: is there a pandas friendly way to a... | <python><pandas><numpy> | 2025-06-27 16:48:55 | 1 | 831 | Raven |
79,682,246 | 15,520,615 | Unable to Read from Azure Event Hub with Spark | <p>I am successfully sending dummy data to Azure Event Hub with the following Python Script:</p>
<pre><code>import dbldatagen as dg
from pyspark.sql.types import IntegerType, StringType, FloatType
import json
from pyspark.sql.types import StructType, StructField, IntegerType, DecimalType, StringType, TimestampType, Row... | <python><azure><pyspark><azure-eventhub> | 2025-06-27 16:45:53 | 0 | 3,011 | Patterson |
79,682,238 | 126,833 | Add header and footer to a second DOCX only that would eventually be appended to a cover page DOCX | <p>I have two DOCX files - ID-1.docx and ID-2.docx - ID-1 being a cover page and ID-2 being the content. ID-2 doesn't have a header and footer and I need the header and footer only in ID-2. Post which I merge the 2 DOCXs.</p>
<pre class="lang-php prettyprint-override"><code>$doc1 = escapeshellarg(DOCX_PATH."$ID-1.... | <python><php> | 2025-06-27 16:34:19 | 0 | 4,291 | anjanesh |
79,682,223 | 9,989,779 | Celery is not running despite correct configuration - using Django, Celery 5+, and Python 3.12+ | <p>Despite what appears to be a correct initial configuration, Celery tasks are not running. The logging system does not show any errors. This is a new setup of Celery version 5+ running on Python 3.12+. Full server-side configuration has been added. All required packages and dependencies have been installed, and the a... | <python><django><celery> | 2025-06-27 16:15:08 | 0 | 2,197 | Maddie Graham |
79,681,743 | 7,791,963 | VSCode debug always sets cwd to test file's folder in Robot Framework project — ignores launch.json setting | <h2>Context</h2>
<p>I'm working on a Robot Framework project using VSCode and the robotcode extension (robotcode-dbiel). In production, we have one git repo for the framework, and one git repo for any test related assets maintained separately.</p>
<p>Therefore when developing / debugging my folder structure looks like ... | <python><visual-studio-code><robotframework> | 2025-06-27 09:53:06 | 0 | 697 | Kspr |
79,681,710 | 1,419,127 | VSCode (on a remote Ubuntu) not offering auto-complete suggestions for any C++ or Python file | <p>I am running VSCode on my Windows 11 laptop as the client of a VSCode server on a Ubuntu 22.4 (Jammy) machine.</p>
<p>This is VScode 1.101.1 (user setup) and my remote Ubuntu has that version too.</p>
<p>I have a folder which is a mixed Python/C++ project. When I open this folder and then files from that folder I ge... | <python><c++><visual-studio-code><autocomplete> | 2025-06-27 09:29:18 | 0 | 1,329 | Charles |
79,681,605 | 4,382,305 | ImportError: Module "django_comments_xtd" does not define a "XtdComment" attribute/class | <p>When I installed django-comments-xtd according the <a href="https://django-comments-xtd.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">documention</a> I got this error:</p>
<pre><code>ImportError: Module "django_comments_xtd" does not define a "XtdComment" attribute/class
</code><... | <python><python-3.x><django> | 2025-06-27 08:04:18 | 1 | 2,091 | Darwin |
79,681,478 | 9,363,181 | Installing external python packages on EMR on EC2 | <p>I want to install external <code>Python packages</code> on <code>EMR with an EC2</code> setup, but currently, apart from bootstrap actions, nothing else seems to be working. The problem with this setup is that if I want to include any new package, I have to create a new cluster with a new set of libraries in the boo... | <python><amazon-web-services><pip><amazon-emr> | 2025-06-27 06:23:04 | 0 | 645 | RushHour |
79,681,477 | 219,153 | Why does keyword argument 'weights' not work when calling NumPy histogram in Numba? | <p>This Python 3.13.5 script with numpy 2.2.6 and numba 0.61.2:</p>
<pre><code>import numpy as np, numba as nb
@nb.njit(fastmath=True)
def f(a, b):
return np.histogram(a, 10, weights=b)
a = np.random.randint(0, 256, (100,)).astype(np.uint8)
b = np.random.randint(0, 256, (100,)).astype(np.uint8)
print(np.histogram(... | <python><numpy><histogram><numba> | 2025-06-27 06:22:27 | 1 | 8,585 | Paul Jurczak |
79,681,111 | 2,613,670 | is CommentedMap.keys() in ruamel.yaml keeping the insertion order? | <p>I am trying to check some internal yaml files, and "fix" them. For that I need to preserve the comments, so I decided to use <a href="https://pypi.org/project/ruamel.yaml/" rel="nofollow noreferrer">ruamel.yaml</a> library.</p>
<p>The thing is that one of the checks is that some "keys", if presen... | <python><yaml><ruamel.yaml> | 2025-06-26 20:28:09 | 1 | 1,904 | Manuelarte |
79,680,981 | 1,998,377 | Pandas Dataframe align/merge/join in similar way to text based file comparison | <p>I want to create a dataframe that aligns the rows of two input dataframes in a similar manner to how a text comparison tool would align text when comparing two files.</p>
<p>For instance, consider the image below, where df_A and df_B are the two input dataframes. They both have triple index <em>year</em>, <em>pos</... | <python><pandas><dataframe> | 2025-06-26 18:02:33 | 1 | 10,834 | Phil Goddard |
79,680,915 | 984,975 | How does NiceGUI object binding (listener) work behind the scenes? | <p>Here is a code example from their great documentation:</p>
<p><a href="https://nicegui.io/documentation/label" rel="nofollow noreferrer">NiceGUI label</a></p>
<pre><code>from nicegui import ui
class status_label(ui.label):
def _handle_text_change(self, text: str) -> None:
super()._handle_text_change(... | <python><nicegui> | 2025-06-26 17:09:25 | 0 | 8,024 | AturSams |
79,680,822 | 16,462,878 | How to clip to max an integer overflow using numpy or opencv | <p>I have an array of the form <code>a = np.array([1], dtype='uint8')</code>.<br />
Now if I add <code>255</code> to <code>a</code> it will overflow and be <code>np.array([0])</code>.</p>
<p>Is there a <em>built-in</em> way to "clip" to value to <code>255</code>?</p>
<p>NumPy has the function <code>np.clip</c... | <python><numpy><opencv><integer-overflow><saturation-arithmetic> | 2025-06-26 15:58:36 | 4 | 5,264 | cards |
79,680,520 | 6,100,177 | Jax persistent cache breaks causes miscompilation? | <p>When I comment the below line ("THIS LINE"), I get correct results (loss decreases), and when I don't, I get broken results (constant loss every iteration):</p>
<pre class="lang-py prettyprint-override"><code>import jax
import numpy as np
from jax import numpy as jnp
import optax
from tqdm import tqdm
from... | <python><jax> | 2025-06-26 12:45:44 | 0 | 1,058 | mwlon |
79,680,467 | 2,537,394 | How to handle loss function with sparse output | <p>I'm trying to create a ML model in TensorFlow that takes in a tensor with shape (128,128,12) and outputs a tensor with shape (128,128,3), where the output dimensions mean (x, y, sensor_number).</p>
<p>With my training data I have the problem that my output is very sparse, meaning I could only take sensor measurement... | <python><tensorflow><keras><loss-function> | 2025-06-26 12:11:27 | 1 | 731 | YPOC |
79,680,007 | 219,153 | Why does the last bin in a NumPy histogram have an unusually high count? | <p>This Python 3.12.7 script with numpy 2.2.4:</p>
<pre><code>import numpy as np
a = np.random.randint(0, 256, (500, 500)).astype(np.uint8)
counts, bins = np.histogram(a, range(0, 255, 25))
print(np.column_stack((counts, bins[:-1], bins[1:])))
counts, bins = np.histogram(a, range(0, 257, 16))
print(np.column_stack((... | <python><numpy><histogram> | 2025-06-26 06:32:22 | 1 | 8,585 | Paul Jurczak |
79,679,773 | 6,074,306 | How did Pandas data frames end up with multiple indexing methods? | <p>This seems like a simple question but I haven't been able to find any historical perspective as to when <code>[]</code>, <code>loc</code> and <code>iloc</code> (and formerly <code>ix</code>) were added, and why.</p>
<p>The docs merely say "Object selection has had a number of user-requested additions".</p>... | <python><pandas> | 2025-06-25 23:53:38 | 3 | 1,421 | n.caillou |
79,679,768 | 6,141,238 | How should CPU time be computed for calculations parallelized with the multiprocessing module? | <p>I am trying to measure the processing time, or CPU time, of a CPU-intensive computation that has been parallelized with <code>multiprocessing</code>. However, simply bookending the parallelization of the computation with <code>process_time()</code> calls and taking the difference is insufficient to do this. For ex... | <python><multiprocessing><python-multiprocessing><cpu-usage><cpu-time> | 2025-06-25 23:41:29 | 1 | 427 | SapereAude |
79,679,557 | 189,230 | Why are we seeing incorrect timings in Datadog APM tracing for simple actions like a Redis GET? | <p>We have Python Django application deployed to AWS EKS on EC2 instances. We use Gunicorn as our web server, although we recently ran Apache + wsgi and saw the same issues. The EC2 instances are m6a.xlarges, the containers themselves have 1500m CPU and 2048MB memory.</p>
<p>We use Datadog APM tracing and we're trackin... | <python><django><redis><datadog><apm> | 2025-06-25 19:13:29 | 0 | 4,820 | Stephen Melrose |
79,679,497 | 1,115,716 | pip error: failed to map segment from shared object | <p>I'm trying to install <code>Wan 2.1</code> on a remote box and I'm seeing the following error when it gets to <code>flash_attn</code>:</p>
<pre><code>Collecting flash_attn (from -r requirements.txt (line 14))
Using cached flash_attn-2.8.0.post2.tar.gz (7.9 MB)
Preparing metadata (setup.py) ... error
error: sub... | <python><linux><pip> | 2025-06-25 18:12:17 | 0 | 1,842 | easythrees |
79,679,286 | 3,225,904 | How to use a decorator to mark a keyword-only mandatory argument as optional in the call signature when statically checked by the IDE? | <p>I have a bunch of functions that all have a certain keyword argument, let's call it <code>kw</code>, which is mandatory and has a specific type <code>T</code>. However, I want to be able to call the functions without necessarily providing that keyword argument, and if it's not present I want it to be generated, prob... | <python><python-typing><pyright> | 2025-06-25 15:18:21 | 1 | 427 | Red |
79,679,253 | 6,141,238 | What are the basic rules for propagating lists and dictionaries across processes using the Manager of the multiprocessing module? | <p>I am trying to use the <code>multiprocessing</code> module to parallelize a CPU-intensive piece code over multiple cores. This module looks terrific in several respects, but when I try to pass lists and dictionaries between processes, changes are not always propagated across the processes as I would expect. What a... | <python><process><reference><python-multiprocessing><multiprocessing-manager> | 2025-06-25 14:56:49 | 1 | 427 | SapereAude |
79,679,101 | 1,862,861 | PyTorch jagged nested tensors massively slow down a DataLoader | <p>The <a href="https://docs.pytorch.org/docs/stable/nested.html#construction" rel="nofollow noreferrer">current recommendation</a> for using nested tensors in PyTorch is to create them with a <code>torch.jagged</code> layout as opposed to the <code>torch.strided</code> layout. However, I have noticed a considerable dr... | <python><pytorch> | 2025-06-25 13:15:50 | 0 | 7,300 | Matt Pitkin |
79,679,016 | 5,828,291 | How can I force pandas to read the last Excel column when it is empty for the first few rows? | <p>I have to parse data from Excel files (and I can't control the incoming format). Four columns have column headers; the fifth column does not, and is often blank -- sometimes there is no data at all in this column, and sometimes one or two rows may have data, so there can be an arbitrary number of blanks in that col... | <python><excel><pandas> | 2025-06-25 12:07:32 | 1 | 403 | Mike Christie |
79,678,882 | 2,232,265 | How to avoid interleaved logs in parallel processing? | <p>Naively parallelizing some tasks that involve logging results in interleaved logs:</p>
<pre><code>import logging
from concurrent.futures import ThreadPoolExecutor
from time import sleep
logger = logging.getLogger(__name__)
def task(n):
logger.info(f"Task {n} started")
sleep(0.001)
logger.in... | <python><logging><parallel-processing> | 2025-06-25 10:28:52 | 1 | 3,274 | zkurtz |
79,678,881 | 5,568,409 | How to repeatedly sample so that the sampling result doesn't change? | <p>I have an array from which I want to select a number of rows, so that the rows selected don't vary if I repeat the sampling process.</p>
<p>In my following code, this is not the case; each time I run the selecting process, I get a different array:</p>
<pre><code>points
array([[ 4.926, 46.153],
[ 5.428, 46.009... | <python><python-3.x><numpy><random> | 2025-06-25 10:28:45 | 2 | 1,216 | Andrew |
79,678,871 | 13,806,869 | Why does this code fail to remove NaN values when run on a specific laptop? | <p>I have a Pandas dataframe that looks like this:</p>
<pre><code>1 | 2
-------|-------
123 | 123
456 | 456
NaN | 789
</code></pre>
<p>The data comes from a spreadsheet which is sent to me quarterly in the same format. I need to convert the dataframe into this format:</p>
<pre><code>list_number | it... | <python><pandas> | 2025-06-25 10:21:34 | 1 | 521 | SRJCoding |
79,678,601 | 3,999,951 | Module showing as missing in PyCharm despite installation | <p>An environment is set up using Poetry v2.1.3. The environment is created from a <code>pyproject.toml</code> which has pandas as one of the dependencies:</p>
<pre class="lang-toml prettyprint-override"><code>[project]
name = "pintail-proj"
version = "0.1.0"
description = ""
readme = &quo... | <python><pycharm><python-poetry> | 2025-06-25 07:11:49 | 1 | 467 | acolls_badger |
79,678,438 | 13,946,204 | Is it possible to generate unique ids based on monotonic clock in python? | <p>I need to implement fast generator of unique IDs in Python. And my idea is:</p>
<pre class="lang-py prettyprint-override"><code>from time import time
def generate(prefix: str) -> str:
return prefix + str(time.monotonic_ns())
</code></pre>
<p>Where <code>prefix</code> is a random string generated once on pro... | <python><uniqueidentifier> | 2025-06-25 03:26:59 | 2 | 9,834 | rzlvmp |
79,678,365 | 14,386,187 | Polars is less memory efficient than pandas | <p>In my application, I want to generate a preview of spreadsheet files that users upload in a memory-efficient manner.</p>
<p>I'm testing the following script using <code>pytest-memray</code>:</p>
<pre class="lang-py prettyprint-override"><code>import pytest
import pandas as pd
import polars as pl
@pytest.fixture
de... | <python><python-polars> | 2025-06-25 00:57:06 | 2 | 676 | monopoly |
79,678,325 | 5,413,581 | Building a sklearn compatible estimator: 'dict' object has no attribute 'requires_fit' | <p>I am trying to build a scikit-learn compatible estimator. I have built a custom class that inherits from <code>BaseEstimator</code> and <code>RegressorMixin</code>. However, when I try to use this, I run into an <code>AttributeError: 'dict' object has no attribute 'requires_fit'</code> that I do not know how to solv... | <python><scikit-learn><regression> | 2025-06-24 23:27:38 | 1 | 769 | Álvaro Méndez Civieta |
79,678,079 | 12,544,460 | Blocking call to socket.socket.accept - when using langchain_postgres.v2.vectorstores | <p>blockbuster.blockbuster.BlockingError: Blocking call to socket.socket.accept - when using langchain_postgres.v2.vectorstores</p>
<p>I'm customizing <a href="https://github.com/langchain-ai/chat-langchain" rel="nofollow noreferrer">chat-langchain repo</a> using PGvectorstore V2</p>
<p>I've been trying with PGVectorSt... | <python><asynchronous><langchain><langgraph> | 2025-06-24 18:47:12 | 0 | 362 | Tom Tom |
79,678,040 | 496,289 | Find number of selected tests programatically | <p>I have a project with 600+ unit tests. These tests use a very time consuming function to log dataframes, which help with debugging. Which is great when I'm debugging 1-2 tests. But when I run all 600 tests this logging takes 30% of total execution time.</p>
<p>What I want to do is disable this expensive logging when... | <python><unit-testing><pytest> | 2025-06-24 18:14:51 | 1 | 17,945 | Kashyap |
79,677,768 | 4,451,315 | How to get mypy to recognise file `-stubs` package | <p>Here's my folder structure:</p>
<pre><code>.
├── foo
│ ├── __init__.py
│ └── classic.py
├── foo-stubs
│ ├── __init__.pyi
│ └── classic.pyi
├── pyproject.toml
└── t.py
</code></pre>
<p>Contents are:</p>
<pre class="lang-console prettyprint-override"><code>$ cat foo/__init__.py
from foo.classic import my_func
... | <python><python-typing><mypy> | 2025-06-24 14:36:07 | 2 | 11,062 | ignoring_gravity |
79,677,547 | 16,563,251 | Infer generic type from metaclass argument | <p>I have a metaclass which creates a <a href="https://typing.python.org/en/latest/reference/generics.html" rel="nofollow noreferrer">generic class</a> parametrized by a type var <code>T</code>.
It also needs to know the same type at runtime, which I currently achieve by providing it as an <a href="https://stackoverflo... | <python><python-typing><metaclass> | 2025-06-24 12:08:57 | 2 | 573 | 502E532E |
79,677,539 | 1,786,137 | Tkinter image label performance issues when updating large image | <p>This is a follow up question from <a href="https://stackoverflow.com/questions/79633834/calling-imagetk-photoimage-in-a-thread-causing-deadlock/79634376#79634376">Calling ImageTk.PhotoImage() in a thread causing deadlock</a></p>
<p>I have so far fixed the deadlock issue following the design in the accepted answer. N... | <python><tkinter> | 2025-06-24 12:00:44 | 0 | 3,863 | Anthony |
79,677,376 | 3,333,319 | Code block partially highlighted in Sphinx | <p>In my Sphinx documentation I have the following code-block:</p>
<pre class="lang-none prettyprint-override"><code>.. code-block:: python
import logging
logging.getLogger('mymodule').setLevel(logging.INFO)
</code></pre>
<p>but when the documentation is rendered the code is only partially highlighted:</p>
<p>... | <python><documentation><python-sphinx> | 2025-06-24 10:02:44 | 1 | 973 | Sirion |
79,677,198 | 1,771,155 | Install local project in editable mode with uv | <p>I have my <code>project</code> and some <code>other-local-project</code> where I want to;</p>
<ul>
<li>Import <code>other-local-project</code> in <code>project</code></li>
<li>Changes in <code>other-local-project</code> are immediately reflected in <code>project</code></li>
</ul>
<pre class="lang-bash prettyprint-ov... | <python><uv> | 2025-06-24 07:56:48 | 1 | 4,886 | Vincent Claes |
79,677,095 | 354,051 | When using nanobind, How to manage GIL and objects in between different threads | <p>I have created a small framework based on <a href="https://github.com/taskflow/taskflow" rel="nofollow noreferrer">taskflow</a> and wrapping it using nanobind.
When framework finishes the graph evaluation, it can send a callback that you can register. I am trying to register a python function but the application is ... | <python><gil><nanobind> | 2025-06-24 06:27:26 | 0 | 947 | Prashant |
79,676,851 | 7,215,853 | Microsoft Graph SDK for Python: Using Patch Operation with the SDKs own models will create false updates | <p>I am using the microsoft graph SDK for CRUD operations on resources like mails, contacts, calendarevents etc.</p>
<p>The graph API uses patch for updating datasets. At the same time, the SDK provides models for all resources available via the Graph API and you are strongly encouraged to use them.</p>
<p>The problem ... | <python><microsoft-graph-api><microsoft-graph-sdks> | 2025-06-23 23:13:04 | 0 | 320 | MrTony |
79,676,799 | 20,895,654 | Python How to type hint the class Any itself | <h2>The Problem And Approach #1</h2>
<p>I have a function that has a parameter which can take some specific types and the type <code>Any</code> (the class itself), which in my case is also the default. Here is a simple example:</p>
<pre><code>def foo(type: type[int] | type[str] | type[Any] = Any) -> Any:
...
</c... | <python><python-typing> | 2025-06-23 21:55:18 | 1 | 346 | JoniKauf |
79,676,658 | 1,857,229 | Efficiently compute all multi-dimensional traces for all offsets and store in matrix | <p>I have a $N\times N \times N$ array $a$ and would like to implement the formula $$ b_{ij} = \sum_k a_{i+k,j+k,k} $$ efficiently.</p>
<p>Right now, I'm doing this via</p>
<pre class="lang-py prettyprint-override"><code>b = np.zeros((N, N))
for i in range(N):
for j in range(N):
m = np.maximum(i, j)
... | <python><numpy><numpy-einsum> | 2025-06-23 19:12:46 | 2 | 1,471 | Uroc327 |
79,676,654 | 11,064,604 | Overthreading in Multiprocessing for ML models | <h3>The problem</h3>
<p>I am running machine learning models in parallel using multiprocessing. When using models with parameters stating the number of threads used- <code>num_threads</code>, <code>num_jobs</code>, etc. - the code works well. Recently, I have had to use models that do not have this parameter. Below ... | <python><machine-learning><multiprocessing> | 2025-06-23 19:09:55 | 0 | 353 | Ottpocket |
79,676,321 | 9,549,068 | How to prevent VS Code from importing global Python env site-packages when using pixi venv? | <h3>situation</h3>
<ul>
<li><p>I created a new Python project with <strong>pixi venv</strong>. <br />
I have this isolated venv, including Python. <br />
I installed <code>pandas</code> etc. <br />
I didn't install <code>plotly</code> etc.</p>
</li>
<li><p>I have Python installed globally. <br />
The global Python env... | <python><visual-studio-code><python-venv><pixi-package-manager> | 2025-06-23 14:22:30 | 2 | 1,595 | Nor.Z |
79,676,236 | 13,756,780 | What size should an `IterableDataset` report when used in a multi-worker `DataLoader`? | <p>Here's a simple dataset and a data loader that uses it:</p>
<pre class="lang-py prettyprint-override"><code>import torch
from torch.utils.data import DataLoader, IterableDataset
class Dataset(IterableDataset):
def __init__(self, size: int):
super().__init__()
self.size = size
def __iter__(... | <python><pytorch><pytorch-dataloader> | 2025-06-23 13:11:26 | 1 | 344 | acl |
79,676,114 | 497,649 | How to add a config to a Plotly object? | <p>In Shiny for Python, how to add a config to a Plotly figure object as usually done by:</p>
<pre><code>fig.show(config={
'modeBarButtonsToRemove': [
'autoScale2d', 'select2d', 'lasso2d', 'pan2d', 'zoom2d', 'zoomOut2d',
'hoverClosestCartesian', 'hoverCompareCartesian',
'toggleSpikelines', ... | <python><plotly><py-shiny> | 2025-06-23 11:51:15 | 1 | 640 | lambruscoAcido |
79,675,883 | 2,918,248 | Python, Use mask to handle MSB is impossible due to infinite precision? | <p>Can anyone explain the last part of the following code to check for overflow?</p>
<p>The code is the solution for LeetCode question 137. Single Number II.</p>
<p>I know it might be overflowing due to the MSB is set.</p>
<p>Base on the problem statement, the number must be in - 2^31 ~ 2^31-1.
We can use deduction to ... | <python> | 2025-06-23 08:46:56 | 0 | 334 | Craig Yang |
79,675,857 | 3,502,079 | How to change environment within the graphical interface of spyder? | <p>I will provide a self answer to this question, it has been bugging me for years and I only recently found out the solution so I suspect that other people have encountered the same issue.</p>
<p>Q: Is it possible to change environments in spyder in the graphical interface?</p>
<p>How I currently do it:</p>
<ol>
<li>S... | <python><user-interface><spyder><virtual-environment> | 2025-06-23 08:25:26 | 1 | 392 | AccidentalTaylorExpansion |
79,675,688 | 9,758,790 | Pausing or adding new breakpoints halfway during running in VSCode makes the Python Exception uncaught, unhandled, and lost | <p>Pausing or adding new breakpoints halfway during debugging in VSCode seems to make the Python Exception uncaught.</p>
<p>The following is a minimal example to reproduce my problem.</p>
<pre class="lang-py prettyprint-override"><code>import contextlib, signal
@contextlib.contextmanager
def time_limit(seconds):
d... | <python><visual-studio-code><vscode-debugger><vscode-python> | 2025-06-23 05:56:20 | 0 | 3,084 | hellohawaii |
79,675,666 | 5,896,591 | How to efficiently log a byte string message in Python 3 | <p>I am trying to port a Python2 library to Python3. (My reason is a bit silly: just that Python3 ships with Ubuntu and so if my library works in Python3 then there are fewer installation steps.)</p>
<p>It is frustrating because all of my byte strings (i.e. <code>bytes</code> objects) are getting escaped, padded with <... | <python><python-3.x><string><python-2.x><porting> | 2025-06-23 05:26:35 | 1 | 4,630 | personal_cloud |
79,675,628 | 11,580,993 | PlotlyExpress not generating bar chart properly | <p>I am trying to create a basic plotly chart:</p>
<pre><code>import pandas as pd
import numpy as np
import plotly.express as px
df = pd.DataFrame({"college_name":list("ABCD"),"in-state_tuition":np.random.randint(5000,7000,4),"out-of-state_tuition":np.random.randint(8000,15000,4... | <python><plotly><plotly-express> | 2025-06-23 04:50:56 | 0 | 1,003 | Rene Chan |
79,675,537 | 4,018,331 | Digital Ocean Function returning generic error code after adding log forwarding | <p>I'm testing a simple function (python) in Digital Ocean App Platform. The function imports psycopg2, connects to an attached Postgres DB, and returns the DB's version. This function was working until I added log forwarding to my DO App and function, to forward logs to Betterstack (Logtail). I did this, because withi... | <python><logging><digital-ocean> | 2025-06-23 00:46:52 | 1 | 1,297 | j3py |
79,675,356 | 1,000,026 | Why is this pandas rolling function exhibiting nonlinear slowdown when run on the cloud? | <p>I moved a library for stock market analysis to the cloud and found strange performance with a key pandas function. It runs reasonably quickly on my low-performance Dell XPS laptop and exhibits expected linear time-to-finish.</p>
<p>When I ran the same code on CodeAnywhere and Google Colab, it tanked.</p>
<p>The exam... | <python><pandas><google-cloud-platform><cloud><rolling-computation> | 2025-06-22 18:28:10 | 1 | 1,044 | David R |
79,675,294 | 794,329 | Pydantic v2 + Python 3.13: PEP 695 type-alias of a generic model returns TypeAliasType (no model_rebuild()) — how can I keep a real BaseModel? | <p>I’m experimenting with Python 3.13 and Pydantic v2.11.7.
My goal is to avoid writing</p>
<pre class="lang-python prettyprint-override"><code>GenericTraining[Discriminate[L1LossConfig]]
</code></pre>
<p>over and over—I’d like a terse alias such that I can do</p>
<pre class="lang-python prettyprint-override"><code>Tra... | <python><python-3.x><pydantic><pydantic-v2> | 2025-06-22 16:59:53 | 0 | 441 | Danilo Horta |
79,675,122 | 5,318,986 | For Pyfixest: how to access adjusted R2 from the summary of feols? | <p>I am using pyfixest for python (not R), and it looks close to impossible to obtain simple statistics, such as number of observations and the R-squared. I get the slopes, and I can get them even in a nice data frame using <code>tidy()</code>, but simple parameters that the output reports cannot be obtained for furthe... | <python><pyfixest> | 2025-06-22 11:54:31 | 1 | 2,767 | Martien Lubberink |
79,674,919 | 25,261,014 | Pip exits when installing build dependencies for pygame-ce | <p>I had pygame (not ce) on my Debian system and then updated it to pygame-ce using <code>pip install —-upgrade pygame-ce</code> and it worked fine, installing pygame-ce==2.5.2 . There were some more recent updates since and I decided to update pygame-ce again using the same command. I am using python 3.9.2 and pip 25.... | <python><pip><meson-build><pygame-ce> | 2025-06-22 05:21:48 | 1 | 362 | DeepThought42 |
79,674,833 | 5,369,275 | Scipy OptimizeWarning: Covariance of the parameters could not be estimated when trying to fit function to data | <p>I'm trying to plot some data with a non-linear fit using the function:
<a href="https://i.sstatic.net/ItIBPAWk.png" rel="noreferrer"><img src="https://i.sstatic.net/ItIBPAWk.png" alt="The function to fit" /></a></p>
<p>kB and Bv being a constant while J'' is the independent variable and T is a parameter.</p>
<p>I tr... | <python><scipy><physics><data-fitting> | 2025-06-22 01:33:49 | 1 | 601 | Tom291 |
79,674,727 | 9,877,065 | opencv cv2.drawcontours contour argument: contour vs [contour] | <p>my input :</p>
<p><a href="https://i.sstatic.net/19nHf6z3.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/19nHf6z3.jpg" alt="enter image description here" /></a></p>
<p>my code :</p>
<pre><code># import the necessary packages
import numpy as np
import argparse
import imutils
import cv2
print("Y... | <python><opencv><image-processing> | 2025-06-21 20:26:00 | 1 | 3,346 | pippo1980 |
79,674,355 | 5,704,198 | How to test a form with unique fields using Hypothesis? | <p>I have a model with an unique constrain linking three fields:</p>
<pre><code>class Bookshelf(models.Model):
house = models.CharField(max_length=2, choices=HOUSE_CHOICES, default='Ar')
room = models.CharField(max_length=20, choices=ROOM_CHOICES)
name = models.CharField(max_length=200)
compartments = m... | <python><testing><pytest><python-hypothesis> | 2025-06-21 10:44:02 | 1 | 1,385 | fabio |
79,674,000 | 16,563,251 | Exception thrown in python magic method is lost on the way | <p>For a project, I want to prevent the use of certain methods in an overriding class.
As this happens rather frequently, I am using a metaclass to block many methods at once (how and why is not within the scope of this question).</p>
<p>This is done by replacing the methods I want to block by a data descriptor, which ... | <python><metaclass><python-descriptors> | 2025-06-20 22:12:50 | 1 | 573 | 502E532E |
79,673,866 | 16,399,497 | How to generate a tar.gz stream to be returned as a StreamingResponse in FastAPI/Starlette? | <p>I'm making an FastAPI/Starlette server which requests to another server (well, S3) large files. These chunks feed a <code>tarfile.TarFile</code> object to produce a <code>.tar.gz</code> stream. This stream should be sent on the fly to a <code>StreamingResponse</code>.</p>
<pre><code>S3 server --files chunks--> My... | <python><python-3.x><python-asyncio><fastapi><starlette> | 2025-06-20 19:13:19 | 1 | 723 | emonier |
79,673,773 | 27,596,369 | How to use @wraps with decorator factories | <p>I have a decorator factory which just multiplies some given numbers.</p>
<pre><code>from functools import wraps
def multiply(numbers):
def decorator(f):
def wrapper(*args, **kwargs):
num1 = numbers[0]
for num2 in numbers[1:]:
num1 = num1 * num2
print(num1)
return f(*a... | <python><function><python-decorators> | 2025-06-20 17:31:23 | 2 | 1,512 | Aadvik |
79,673,440 | 6,197,439 | Redraw a QPushButton after .setDown is called? | <p>Consider the following example:</p>
<pre class="lang-py prettyprint-override"><code>import sys
import time
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox, QVBoxLayout
from PyQt5.QtCore import QTimer
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("Minimal PyQt... | <python><pyqt5> | 2025-06-20 13:16:56 | 0 | 5,938 | sdbbs |
79,673,223 | 21,294,350 | clickable elements throw error "could not be scrolled into view" in selenium | <p>I try to scrape <a href="https://www.anytimemailbox.com/s/new-york-42-broadway" rel="nofollow noreferrer">https://www.anytimemailbox.com/s/new-york-42-broadway</a>. I checked <a href="https://stackoverflow.com/a/61343018/21294350">https://stackoverflow.com/a/61343018/21294350</a> and used <code>driver.execute_script... | <python><selenium-webdriver><web-scraping> | 2025-06-20 10:23:31 | 1 | 782 | An5Drama |
79,672,988 | 10,134,422 | Why can't (langchain) AzureOpenAI find a model that AzureChatOpenAI can? | <p>Invoking a request using AzureChatOpenAI returns response as expected:</p>
<pre><code>import os
from dotenv import load_dotenv
from langchain_openai import AzureChatOpenAI
load_dotenv()
llm = AzureChatOpenAI(
azure_endpoint=os.getenv("AZURE_ENDPOINT"),
api_key=os.getenv("TOOL_KEY"),
... | <python><langchain><large-language-model><azure-openai> | 2025-06-20 07:17:40 | 1 | 460 | Sanchez333 |
79,672,973 | 8,913,983 | Pandas str in col failing to find value | <p>I have a <code>df</code> like so:</p>
<pre><code>RangeIndex: 115506 entries, 0 to 115505
Series name: Email
Non-Null Count Dtype
-------------- -----
115506 non-null object
dtypes: object(1)
memory usage: 902.5+ KB
</code></pre>
<p>I am searching some string values in the df</p>
<pre><code>'abc' in df.Email r... | <python><pandas> | 2025-06-20 07:03:47 | 0 | 4,870 | Jonas Palačionis |
79,672,719 | 19,459,262 | How do I set custom axis titles for a go.Figure()? | <p>I have a graph objects Figure and I want to set custom axis titles. I've found how to do it with <code>update_layout()</code> for plotly express figures, but I haven't found a way to do it with a <code>go.Figure()</code>. (Using that instead of a plotly express graph because I'm not sure how to graph an exponential ... | <python><plotly><plotly.graph-objects> | 2025-06-19 23:00:51 | 2 | 784 | Redz |
79,672,674 | 10,083,382 | Log Metrics in Azure using MLflow | <p>I have a component registered within MLStudio that contains code to run a Promptflow pipeline. I am executing the flow using an AzureML pipeline, following the <a href="https://microsoft.github.io/promptflow/cloud/azureai/use-flow-in-azure-ml-pipeline.html" rel="nofollow noreferrer">documentation</a> and <a href="ht... | <python><azure><azure-machine-learning-service><mlflow><azure-ml-pipelines> | 2025-06-19 21:48:24 | 0 | 394 | Lopez |
79,672,349 | 15,842 | Handle shadowed attribute in multiple inheritance | <p>What is the best way to handle attribute shadowing from multiple inheritance?</p>
<p>Intended behavior is to end up with a <code>Field</code>.</p>
<pre><code>from pydantic import BaseModel
class Parent(object):
value: int = 1
class Shadow(BaseModel, Parent):
value: int = 2
Shadow()
</code></pre>
<p>Option... | <python><pydantic> | 2025-06-19 16:08:07 | 0 | 21,402 | Gregg Lind |
79,672,338 | 1,422,096 | Matplotlib button "Save data as CSV" in the toolbar next to the "Save the figure as PNG" button | <p>This works to add a "Save as CSV" button in a Matplotlib plot:</p>
<pre><code>import matplotlib.pyplot as plt
from matplotlib.widgets import Button
import csv
X = [1, 2, 3, 4, 5]
Y = [2, 3, 5, 7, 11]
def save_as_csv(event):
file_path = 'data.csv'
with open(file_path, 'w', newline='') as file:
... | <python><matplotlib> | 2025-06-19 16:00:46 | 1 | 47,388 | Basj |
79,672,310 | 21,294,350 | Is splash:select different from document.querySelector? | <p>example link <a href="https://www.anytimemailbox.com/s/new-york-42-broadway" rel="nofollow noreferrer">https://www.anytimemailbox.com/s/new-york-42-broadway</a></p>
<pre class="lang-lua prettyprint-override"><code>function main(splash)
local button = splash:select('div[class="t-disc"]>a')
assert(but... | <javascript><python><lua><scrapy-splash><splash-js-render> | 2025-06-19 15:41:58 | 1 | 782 | An5Drama |
79,672,309 | 27,596,369 | Flask-login is making Flask return 404 error | <p>I have a script which is basically a blog post website, it has multiple routes and uses many libraries. Here is a MRE of my code.</p>
<pre><code>from flask import Flask, render_template, request
from flask_login import UserMixin, LoginManager, current_user
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm ... | <python><sqlite><flask><sqlalchemy><flask-login> | 2025-06-19 15:40:38 | 1 | 1,512 | Aadvik |
79,672,205 | 5,452,365 | python-gql async execute_batch error with httpx transport | <p>I am following this example to implement client with httpx transport. However, I'm getting this error: <code>AttributeError: 'AsyncClientSession' object has no attribute 'execute_batch'</code></p>
<p>This is the code that I'm trying to execute:</p>
<pre><code>from gql import Client, GraphQLRequest
from gql.transport... | <python><https><gql> | 2025-06-19 14:16:29 | 1 | 11,652 | Rahul |
79,672,095 | 9,877,065 | Detecting inflection points/local minima in openCv Python contours objects to differentiate shapes | <p>I am trying to answer <a href="https://stackoverflow.com/questions/79640660/detecting-circular-elliptical-shape-with-python-opencv-or-any-other-lib/79653025#79653025">Detecting circular/elliptical shape with Python openCv (or any other lib)</a>.
In trying to get the best results I would like to find a way to differe... | <python><opencv><image-processing><shapes> | 2025-06-19 13:05:12 | 1 | 3,346 | pippo1980 |
79,672,094 | 12,468,438 | Tensorflow speed of tf.nn.conv2D used instead of opencv GaussianBlur | <p>I'm trying to move some computer vision tasks to tensorflow. The most intensive ops are convolutions, like GaussianBlur. The timings I get using timeit suggest that the GPU equivalent is >10 x slower.</p>
<ul>
<li>The stdout reports "WARNING:tensorflow:AutoGraph could not transform ... and will run it as-is.... | <python><tensorflow><opencv><neural-network><convolution> | 2025-06-19 13:04:44 | 0 | 314 | Frank_Coumans |
79,672,067 | 12,550,791 | Issue while typing a recursive function with list unpacking | <p>I'm trying to correctly type the following function in Python 3.10</p>
<pre><code>from typing import overload
@overload
def joinpath(*path_pieces: str) -> str: ...
@overload
def joinpath(*path_pieces: list[str] | str) -> list[str]: ...
def joinpath(*path_pieces: list[str] | str) -> list[str] | str:
&qu... | <python><python-typing><mypy> | 2025-06-19 12:44:45 | 0 | 391 | Marco Bresson |
79,672,036 | 14,463,396 | Simpy model with closure, entities grabbing resource while closing code running | <p>I have a model where:</p>
<ul>
<li><p>resources are available between opening hours (8am-8pm).</p>
</li>
<li><p>Any entities using resources are kicked out at 1 minute to 8pm, then
a closing function is run to claim all the resources with a -1
priority for 12 hours until 8am</p>
</li>
<li><p>The resources stop accep... | <python><simpy> | 2025-06-19 12:16:58 | 2 | 3,395 | Emi OB |
79,671,980 | 2,123,706 | memoryError when using to_sql and sqlalchemy | <p>I am copying data from postgres to SSMS, and using sqlalchemy as the go between.</p>
<p>I read from postgress successfully, and push into a pandas dataframe.</p>
<p>I write most of the tables to SSMS successfully, but for a few receive the following error: <code>MemoryError</code></p>
<p>I get around this by inserti... | <python><sqlalchemy> | 2025-06-19 11:17:30 | 1 | 3,810 | frank |
79,671,957 | 9,251,158 | Equivalent of Pandas `to_feather` for Series | <p>I want to save a Pandas series to disk in feather format:</p>
<pre><code>data.to_feather(filepath)
</code></pre>
<p>but I get this error:</p>
<pre><code>AttributeError: 'Series' object has no attribute 'to_feather'
</code></pre>
<p>I use <code>.to_feather()</code> on dataframes; what is the equivalent for series? If... | <python><pandas><feather> | 2025-06-19 11:00:37 | 1 | 4,642 | ginjaemocoes |
79,671,934 | 1,841,143 | ValueError: No valid stream found in input file. Is -1 of the desired media type? | <p>While using <code>torchcodec</code> with the following code</p>
<pre class="lang-py prettyprint-override"><code>import torchcodec
file_path = "/path/to/episode_000000.mp4"
x = torchcodec.decoders.VideoDecoder(file_path, seek_mode="approximate")
</code></pre>
<p>I got the following error:</p>
<pre... | <python><ffmpeg><pytorch><torchcodec><lerobot> | 2025-06-19 10:42:05 | 1 | 3,754 | Haozhe Xie |
79,671,740 | 6,553,631 | Algorithm to extract the common part of all strings in a list | <p>My goal is to classify and show the types of errors in log files. I've solved the part of clustering them into buckets, but now I want to show the user the error string that is common across all the errors in each bucket. Right now I'm showing the user the first string of the bucket, but it would be nicer to show th... | <python><string><algorithm> | 2025-06-19 08:16:50 | 1 | 765 | tgonzalez89 |
79,671,560 | 22,434,294 | How can I insert an image with a clickable hyperlink on the first page of a PDF using Python? | <p>I'm trying to programmatically add a clickable image icon to the top-left corner of the first page of a PDF file using Python. I want the icon to link to a URL.</p>
<p>what I tried using reportlab and PyPDF2:</p>
<pre><code>from PyPDF2 import PdfReader, PdfWriter
from reportlab.pdfgen import canvas
from reportlab.li... | <python><pypdf><reportlab> | 2025-06-19 05:25:27 | 2 | 577 | nicholaspooran |
79,671,464 | 219,153 | What is the reason of this performance discrepancy between NumPy and Numba? | <p>This Python 3.12.7 script with NumPy 2.2.4 and Numba 0.61.2:</p>
<pre><code>import numpy as np, timeit as ti, numba as nb
def f0(a):
p0 = a[:-2]
p1 = a[1:-1]
p2 = a[2:]
return (p0 < p1) & (p1 > p2)
def f1(a):
p0 = a[:-4]
p1 = a[1:-3]
p2 = a[2:-2]
p3 = a[3:-1]
p4 = a[4:]
return ((p0 ... | <python><numpy><benchmarking><numba> | 2025-06-19 02:19:48 | 1 | 8,585 | Paul Jurczak |
79,671,212 | 2,153,235 | Force "os" or "posixpath" to use forward slashes? | <p>To get paths that use forward slash as a path separator, Google AI says to use the <code>posixpath</code> module instead of the <code>os</code> module. However, I find that it still uses backslashes:</p>
<pre><code>>>> import os
>>> os.path.abspath('LoadJSON.py')
'C:\\cygwin64\\home\\User.Name\\pr... | <python><python-3.x><path><path-separator> | 2025-06-18 19:28:35 | 0 | 1,265 | user2153235 |
79,671,202 | 9,971,619 | Why is pydantic_settings not parsing the correct dotenv file? | <p>I have a FastAPI app written in Python. I want to have 2 environments for the app: <em>dev</em> and <em>local</em>. For managing the environments, I have kept 2 files namely <code>.local.env</code> and <code>.dev.env</code>. Also I have a standalone <code>.env</code> file, which I later plan to use for production pu... | <python><fastapi><dotenv><pydantic-v2><pydantic-settings> | 2025-06-18 19:11:38 | 1 | 329 | Kalpadiptya Roy |
79,670,998 | 11,063,709 | jax.random.uniform causing segmentation fault when called on GPU but not on CPU, nor is jax.random.normal crashing | <p>I ran the following 4 commands at the command line (bash):</p>
<pre><code>JAX_PLATFORM_NAME=cpu python -c "import jax; import jax.numpy as jnp; key = jax.random.PRNGKey(1); print(jax.random.uniform(key, (2, 2),))"
JAX_PLATFORM_NAME=cpu python -c "import jax; import jax.numpy as jnp; key = jax.random.P... | <python><jax> | 2025-06-18 16:21:11 | 0 | 1,442 | Warm_Duscher |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.