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,635,883
6,479,666
Telethon session not authorized with docker container
<p>I have a python script within a docker container. I mount a folder with .session files as a volume to the container.</p> <p>When I connect to telegram locally, with jupyter, it works perfectly fine:</p> <pre class="lang-py prettyprint-override"><code>messages = [] async with TelegramClient(&quot;../volumes/telethon_...
<python><docker><telethon>
2025-05-23 16:17:45
0
567
Michail Highkhan
79,635,401
7,002,525
Google Cloud and project ID from google.auth.default() in docker container
<p>I'm playing Whac-A-Mole with Google Cloud authentication. Sorry for the lengthy question but since I have no idea where the problem is, I'm trying to give enough context.</p> <p>With Python, calling <a href="https://googleapis.dev/python/google-auth/latest/reference/google.auth.html#google.auth.default" rel="nofollo...
<python><docker><authentication><google-cloud-platform><gcloud>
2025-05-23 11:13:26
0
706
teppo
79,635,390
4,764,604
PyTorch and Streamlit interaction error: "Tried to instantiate class '__path__._path', but it does not exist!"
<p>I'm developing an application that uses Streamlit and PyTorch (through the huggingface <code>transformers</code> library) to analyze system requirements with a language model. However, I'm encountering the following recurring error:</p> <pre class="lang-py prettyprint-override"><code>Examining the path of torch.clas...
<python><machine-learning><pytorch><huggingface-transformers><streamlit>
2025-05-23 11:06:14
1
3,396
Revolucion for Monica
79,635,263
6,643,185
CrewAI Deployment Issue with Permisson in AWS Lambda
<p>Good day all, I have a <strong>fastapi</strong> application API's that connect to my <strong>CrewAI</strong> agents. It is working fine as expected in local. The CrewAI agent uses the <strong>PDFSearchTool</strong> of CrewAI. The PDFSearchTool create a vector DB of the PDF that is connected. So the code creates a fo...
<python><amazon-web-services><aws-lambda><fastapi><crewai>
2025-05-23 09:41:26
0
619
Prifulnath
79,635,201
12,415,855
Using Proxies with Selenium / add_to_capabilities error?
<p>I am using Selenium with proxies a long time with the following code:</p> <pre><code>import os from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.proxy import Proxy, ProxyType from selenium.webdrive...
<python><selenium-webdriver>
2025-05-23 09:11:33
0
1,515
Rapid1898
79,635,098
13,392,257
undetected_chromedriver error: Too many open files
<p>I am running this selenium-script on my Linux server. After 10 hours I see an error</p> <blockquote> <p>Too many open files</p> </blockquote> <p>My code:</p> <pre><code>logging.basicConfig( level=logging.INFO, format=&quot;%(asctime)s [%(levelname)s] %(message)s&quot;, handlers=[ logging.FileHand...
<python><selenium-webdriver><undetected-chromedriver>
2025-05-23 08:11:46
2
1,708
mascai
79,635,073
388,506
How to compute on load?
<p>I have a model like this:</p> <pre class="lang-py prettyprint-override"><code># Calculated Fields request = fields.Many2one('job.request', string='Request', required=True) e_name = fields.Char('Nama Asset', store=False, compute=&quot;_compute_initial&quot;) @api.depends('request') def _compute_initial(self): ...
<python><odoo><odoo-18>
2025-05-23 07:55:03
1
2,157
Magician
79,634,952
1,367,705
JS seems not to work in Python / Selenium / Google Chrome - page is not loading
<p>I would like to automate the process of checking domain on <a href="https://haveibeensquatted.com/" rel="nofollow noreferrer">https://haveibeensquatted.com/</a>. I wrote a simple code in Python Selenium, but it seems the page has problems with loading results in selenium - but normally (when I just click and wait) i...
<python><selenium-webdriver><selenium-chromedriver>
2025-05-23 06:28:35
2
2,620
mazix
79,634,585
9,576,988
Removing diacritics in Python
<p>Referencing the book Fluent Python, I've been trying to normalize characters and toss out their diacritics. I am facing an issue where there are still some diacritics which stick around like ´ and ˜ which combine with following characters (see image)</p> <pre class="lang-py prettyprint-override"><code>import unicode...
<python><unicode><diacritics><unicode-normalization>
2025-05-22 21:57:41
0
594
scrollout
79,634,531
686,334
How can I fix Error EOF occurred in violation of protocol (_ssl.c:2393) with AWS IOT and MQTT
<p>I am running python to send MQTT messages to an AWS-IOT server. It runs on a Raspberry Pi, and sends a message each time a button is pressed. It works for a while, but soon a message is sent that does not get received by the MQTT Test Client. If I hit the button again, and it tries to send a message I get the error:...
<python><aws-iot>
2025-05-22 21:00:13
1
534
CrabbyPete
79,634,492
1,477,064
Autograph / tf.function produce bad Tensorboard Graph
<p>When using TensorBoard with the following code, the graph generated from tf.function is not fully connected.</p> <p>I backported the code to tensorflow V1, and it shows the expected graph.</p> <p>Am I doing something wrong with tf.function? Is there any way to better annotate the operations?</p> <hr /> <p>Unrelated ...
<python><tensorflow><tensorboard><tensorflow-autograph>
2025-05-22 20:30:10
0
4,849
xvan
79,634,346
808,151
Preserve line breaks in XML attributes when parsing with lxml
<p>I'm trying to batch-process a couple of XML files through a python script, with the XML files having line breaks in some of their attributes like so:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;xml&gt; &lt;test value=&quot;This is a test with lin...
<python><lxml><elementtree>
2025-05-22 18:35:09
1
12,702
Tim Meyer
79,634,313
3,357,935
How do I delete a password set using Python's keyring library?
<p>I used the <code>keyring</code> library in Python to store a password needed to logon to an external service.</p> <pre><code>import keyring keyring.set_password(&quot;service_name&quot;, &quot;username&quot;, &quot;my_password&quot;) password = keyring.get_password(&quot;service_name&quot;, &quot;my_username&quot;)...
<python><python-3.x><python-keyring>
2025-05-22 18:11:31
1
27,724
Stevoisiak
79,634,153
10,331,351
opening privatekey from string rather than file in python 3?
<p>I found some python code to read a private key from a file to connect to Snowflake and it works fine</p> <pre><code>with open(&quot;rsa_key_1.p8&quot;, &quot;rb&quot;) as key: p_key= serialization.load_pem_private_key( key.read(), password=None, backend=default_backend() ) </code></pr...
<python><snowflake-cloud-data-platform>
2025-05-22 16:17:32
1
3,795
Eric Mamet
79,634,056
16,389,095
How to build a generic user control in Python Flet
<p>I'm trying to develop a custom user control in Flet (version==0.28.2). The page contains a button_click event that implements the control:</p> <pre><code>def button_on_click(e): page_content.controls=[Create_New_Db_UI()] page.update() </code></pre> <p>The user control is defined by the class:</p> <pr...
<python><flutter><flet>
2025-05-22 15:13:54
0
421
eljamba
79,634,001
215,487
Why does "pip list" not like broken pipes on the bash command line?
<p>I'm using a bash terminal.</p> <p>I just wanted to peek at the first few names of installed python packages:</p> <pre><code>pip list | head -n5 </code></pre> <p>And got an error message:</p> <pre><code>Package Version ------------------ ---------------- attrs 21.2.0 Automat 20.2.0 ...
<python><bash><pip><pipe>
2025-05-22 14:47:50
2
11,401
Christopher Bottoms
79,633,998
1,060,420
Remove resource from event where caller is not the organizer using Google Calendar API?
<p>I'm trying to remove resources (conference rooms) that have declined events. It works as expected for events where the caller is the event organizer, but not if another person is the organizer. The event <em>is</em> modifiable and I can manually remove the room using the Google Calendar web interface.</p> <p>This is...
<python><google-calendar-api><google-api-python-client>
2025-05-22 14:46:53
1
1,773
Allan Beaufour
79,633,868
1,422,096
matplotlib.animation.FuncAnimation lagging when resizing the plot window (more than 5 seconds)
<p>The code below generates random data, and displays it in realtime with Matplotlib. The sliders allow the user to change the y-axis range. All of this works.</p> <p><strong>Problem</strong>: when resizing the window size or moving the window, there is a performance problem: the plot is lagging during 5 seconds (and s...
<python><matplotlib><real-time><matplotlib-animation><real-time-data>
2025-05-22 13:33:38
2
47,388
Basj
79,633,834
1,786,137
Calling ImageTk.PhotoImage() in a thread causing deadlock
<p>I am working on a camera applicaiton where I need to get images from camera buffer and display it in a TK label live:</p> <pre class="lang-py prettyprint-override"><code>def display_thread_run(self): while self.is_acquiring: image_data = self.camera.get_next_image() # --- some image conversion me...
<python><tkinter><python-imaging-library>
2025-05-22 13:13:30
1
3,863
Anthony
79,633,804
447,426
how to run test in databricks default python bundle?
<p>I created a databricks bundle &quot;processing&quot; with <code>databricks bundle init</code> using default python template. I am able to &quot;upload and run&quot; <code>main.py</code> <a href="https://i.sstatic.net/65OUVaxB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/65OUVaxB.png" alt="enter ima...
<python><visual-studio-code><databricks><azure-databricks>
2025-05-22 12:57:29
0
13,125
dermoritz
79,633,652
3,084,842
Fill in elements of large matrix with same value
<p>I have a large matrix where I want to assign the same value(s) to many matrix elements. Is there a more efficient way to do this rather than iterating over each column and row using for loops?</p> <p>Here is an example:</p> <pre><code>import numpy as np a = 0.5 b = 0.6 M = np.zeros((16,16)) # empty matrix np.fi...
<python><numpy>
2025-05-22 11:34:10
2
3,997
Medulla Oblongata
79,633,608
11,063,709
How to select between using a `jax.lax.scan` vs a `for` loop when using JAX?
<p>I am a JAX beginner and someone experienced with JAX told me that if we have repeated calls to a <code>scan</code>/<code>for</code> loop (e.g. when these are themselves wrapped by another <code>for</code> loop), it might be better to leave the loop as a <code>for</code> instead of converting it to a <code>scan</code...
<python><jax>
2025-05-22 11:03:11
1
1,442
Warm_Duscher
79,633,258
29,295,031
How to make plotly text bold using scatter?
<p>I'm trying to make a graph using <code>plotly</code> library and I want to make some texts in <strong>bold</strong> here's the code used :</p> <pre class="lang-py prettyprint-override"><code>import plotly.express as px import pandas as pd data = { &quot;lib_acte&quot;:[&quot;test 98lop1&quot;, &quot;test9665 opp...
<python><pandas><dataframe><plotly>
2025-05-22 07:18:10
3
401
user29295031
79,633,161
1,879,101
specialbots.UploadRobot().run(): looks like I cannot catch an exception?
<p>In <a href="https://gitlab.com/vitaly-zdanevich/upload-to-commons-with-categories-from-iptc/-/blob/master/upload_to_commons_with_categories_from_iptc.py" rel="nofollow noreferrer">my script</a>, I want to catch the case when user uploading a file to Commons that already exists.</p> <p>My logs:</p> <pre><code>Uploadi...
<python><pywikibot>
2025-05-22 06:01:00
1
15,411
Vitaly Zdanevich
79,633,071
4,755,229
How do I color 3d triangular mesh using another scalar in matplotlib?
<p>I have 3d vertex position data <code>(x,y,z)</code>, scalar values at each vertex <code>v</code>, and vertex indices for each triangle <code>tri</code>.</p> <p>If I were to draw the surface geometry itself, I could use <code>plot_trisurf</code>. If I were to draw a 2D projected plot with each triangle colored accord...
<python><matplotlib><matplotlib-3d>
2025-05-22 04:15:30
1
498
Hojin Cho
79,633,000
270,043
Number of completed tasks exceeds total tasks in PySpark
<p>I have the following (simplified) code running in PySpark.</p> <p><code>df</code> is a PySpark dataframe with 2B rows. I keep hitting resource issues when running such a large dataframe, so I'm trying to get a subset of the dataframe to work on.</p> <pre><code>df_10M = df.limit(10000000) df_a = df_10M.withColumn(......
<python><pyspark>
2025-05-22 02:37:30
1
15,187
Rayne
79,632,792
5,450,919
Error Connecting to Oracle Data Warehouse DW2_DEV: Unsupported Password Verifier Type in Python-oracledb Thin Mode
<h3>Description:</h3> <p>I am attempting to connect to the DW2_DEV database within our Oracle data warehouse using Python 3.11 and the oracledb library version 3.1.1. While I can successfully connect to the DW3_UAT database using a different set of credentials, I encounter an error when trying to connect to DW2_DEV.</p...
<python><oracle-database><python-oracledb>
2025-05-21 21:35:56
0
629
b8con
79,632,701
2,514,130
How to save xls file in pandas 2.0+
<p>Is there still a way to save an xls file in modern pandas (i.e. since <a href="https://github.com/pandas-dev/pandas/pull/49296" rel="nofollow noreferrer">they dropped xlwt</a>)? For example, I can save an xlsx file like so:</p> <pre><code>import pandas as pd def create_excel_files(): # Create first sheet data ...
<python><pandas><xls>
2025-05-21 20:09:46
2
5,573
jss367
79,632,535
11,657,578
python core module to create 1 log file for each call
<p>I have below code for logging, in a core_replication.py file. This file is called by multiples python scripts (say table1.py, table2.py), each of which is to replicate a single table from source to target. core_replication.py takes care of creating a unique log file for each call. Each call can be a direct call to t...
<python>
2025-05-21 17:59:32
0
325
Srinivasarao Kotipatruni
79,632,404
1,204,527
Django annotate with ExtractMonth and ExtractYear doesnt extract year
<p>I have this model:</p> <pre class="lang-py prettyprint-override"><code>class KeyAccessLog(models.Model): key = models.ForeignKey( Key, related_name=&quot;access_logs&quot;, on_delete=models.CASCADE ) path = models.CharField(max_length=255) method = models.CharField(max_length=10) ip_addre...
<python><django><django-orm>
2025-05-21 16:28:23
1
4,381
Mirza Delic
79,632,374
2,514,130
How to get full, raw, serialized prompt that is sent to LLM using Instructor
<p>My question is specifically for use with the Python <a href="https://python.useinstructor.com/" rel="nofollow noreferrer">Instructor</a> library. Is there a way to get the full, raw, serialized prompt that is sent to an the LLM? I saw that this has come up before in <a href="https://github.com/567-labs/instructor/is...
<python><pydantic><large-language-model><google-gemini>
2025-05-21 16:12:15
0
5,573
jss367
79,632,332
11,188,140
Efficient way to replace list elements with COMPUTED values
<p>Consider a 2d python list (ie: lst2) and a matrix that gives the value of each adjacent pair of letters (ie: value_matrix).</p> <pre><code>lst2 = [['acba', 'ca'], ['babab', 'ca', 'bc']] value_matrix = [['aa', 0], ['ab', 3], ['ac', 5], ['ba', 2], ['bb', 0], ['bc', 9], ['ca', 7], ['cb', 4], ['cc', 0]] </code></pre>...
<python><list>
2025-05-21 15:42:10
1
746
user109387
79,632,223
2,074,831
Selecting a specific column of a select query
<p>I defined a <code>Usr</code> sqlalchemy table:</p> <pre class="lang-py prettyprint-override"><code>from sqlalchemy import Column, Integer, String, select from sqlalchemy.orm import declarative_base Base = declarative_base() class Usr(Base): # user table __tablename__ = &quot;usr&quot; usr_id = Column(Intege...
<python><sqlalchemy>
2025-05-21 14:40:19
2
3,974
sevan
79,632,156
18,744,117
How to mark a class as abstract in python (no abstract methods and in a mypy compatible, reusable way)?
<p>I'm trying to make it impossible to instantiate a class directly, without it having any unimplemented abstract methods.</p> <p>Based on other solutions online, a class should have something along the lines of:</p> <pre class="lang-py prettyprint-override"><code>class Example: def __new__(cls,*args,**kwargs): ...
<python><python-typing><mypy>
2025-05-21 14:01:51
1
683
Sam Coutteau
79,632,061
3,760,519
What do I need to do in pydantic to support a FastAPI endpoint involving a sparse matrix?
<p>I am aware of apparently similar questions, such as</p> <ul> <li><a href="https://stackoverflow.com/questions/76937581/defining-custom-types-in-pydantic-v2">Defining custom types in Pydantic v2</a></li> <li><a href="https://stackoverflow.com/questions/77100890/pydantic-v2-custom-type-validators-with-info">Pydantic v...
<python><scipy><fastapi><pydantic>
2025-05-21 13:17:58
1
2,406
Chechy Levas
79,632,060
11,167,163
Why does pct_change() still raise FutureWarning after using .ffill() in pandas?
<p>I'm trying to compute percentage changes in a pandas Series, while handling NaN values correctly and avoiding any <code>FutureWarning</code>. However, I'm stuck between two conflicting warnings.</p> <pre><code>sub_df[f&quot;Δ {col}&quot;] = sub_df[col].ffill().pct_change() </code></pre> <p>This seems like the proper...
<python><pandas><dataframe>
2025-05-21 13:17:51
1
4,464
TourEiffel
79,631,903
10,192,256
Reducing number of identical BLAS DLLs in pyinstaller generated distributable
<p>I created an executable with <code>pyinstaller</code> and noticed that even after some size reduction tricks (creating a custom environment, using OpenBLAS instead of MKL) the package comes out quite big. When looking into the <code>_internal</code> directory I found that the same DLL has been copied there four time...
<python><conda><pyinstaller><openblas>
2025-05-21 11:47:02
1
1,908
André
79,631,902
2,829,863
Setting font size for text and tables using styles approach with python-docx library
<p>I am using the <a href="https://python-docx.readthedocs.io/en/latest/" rel="nofollow noreferrer">python-docx</a> library to create a docx file that contains text and a table right after it. I want to set the text size to 12 and table size to 9 point using <strong>styles</strong>. But the size of all the text, includ...
<python><docx><python-docx>
2025-05-21 11:45:56
0
787
Comrade Che
79,631,853
10,232,932
Suppress / Do not show Uploading artifacts widget in databricks
<p>I am running machine learning algorithm in databricks in a Python notebook, how can I suppress / do not show the uploading artifacts widgets in databricks, they are costing to much memories and I do not want to show them. I would expect that there is a option that it is not shown as all.</p> <p><a href="https://i.ss...
<python><databricks>
2025-05-21 11:12:48
0
6,338
PV8
79,631,743
2,819,689
How to replace sh? Error: No module named 'fcntl'
<p>I am running code on Windows and I have this line</p> <pre><code>pip = sh.Command(os.path.join(sys.exec_prefix,&quot;bin&quot;,&quot;pip&quot;)) </code></pre> <p>got</p> <pre><code>No module named 'fcntl' </code></pre> <p>I tried to replace it this way</p> <pre><code>def pip(*args): result = subprocess.run( ...
<python><windows>
2025-05-21 10:00:51
1
2,874
MikiBelavista
79,631,370
9,393,952
Apify Update breaks python debugging capabilities
<p>I'm working with apify for web scraping and I recently updated from <code>apify-cli</code> <code>0.21.6</code> to <code>0.21.7</code><br /> I use the python SDK and for debugging I use <code>pdb.set_trace()</code> or <code>breakpoint()</code><br /> When I updated apify-cli the code keeps stopping at the break points...
<python><web-scraping><apify>
2025-05-21 01:19:18
0
826
Cristobal Sarome
79,631,318
3,427,866
How to access model method in enumerate of list in Python?
<p>I'm new to python and I've managed to populate a list with instances of my model.</p> <pre><code># requisition.py from pydantic import BaseModel from app.schemas.job_information import JobInformation class Requisition(BaseModel): # Base fields (common between internal and external) index: int = 0 conte...
<python><list><pydantic>
2025-05-20 23:57:14
2
1,743
ads
79,631,317
16,100,017
How do you change the position (column and row) of a PyQt QWidget inside a QTableWidget?
<p>I want to move a QWidget from one position to another. I tried the following:</p> <pre><code>import sys from PySide6.QtWidgets import ( QApplication, QMainWindow, QTableWidget, QLabel, QPushButton, QVBoxLayout, QWidget ) class MainWindow(QMainWindow): def __init__(self): super().__init__() ...
<python><pyqt><pyqt5><pyside><pyside6>
2025-05-20 23:54:51
1
647
Rik
79,631,313
949,664
Updated from Django 3.2 to 5.2, now I'm getting "Obj matching query does not exist"
<p>I'm using Django in a non-Django project (Postgresql 17 under the hood) purely to make my unit tests easier. I've defined all my models like this:</p> <pre class="lang-py prettyprint-override"><code>class Bar(models.Model): internal_type = models.TextField() class Meta: managed = False db_ta...
<python><django><postgresql>
2025-05-20 23:47:30
0
1,128
sagargp
79,631,280
2,003,686
Counting objects in YOLO11 defining several lines
<p>I'm using an <a href="https://docs.ultralytics.com/guides/object-counting/" rel="nofollow noreferrer">example from Ultralytics (YOLOv11)</a> to count apples on a conveyor belt. It defines a line across the frame and counts how many apples cross that line using the <strong>ObjectCounter</strong> solution provided by ...
<python><computer-vision><yolo><ultralytics><yolov11>
2025-05-20 23:05:40
0
1,940
rodrunner
79,631,048
2,971,574
Different behaviour of databricks-connect vs. pyspark when creating DataFrames
<p>I've got a project where I develop an ETL pipeline in VS Code using the Databricks extension which is based on the Python package &quot;databricks-connect&quot;. To run unit tests on functions I use pytest as well as the VS Code extension &quot;Testing&quot;. In gitlab I want to run those unit tests as well when spe...
<python><pyspark><databricks><azure-databricks><databricks-connect>
2025-05-20 19:22:16
1
555
the_economist
79,631,026
1,719,931
_metadata properties do not work with pyjanitor
<p><a href="https://pandas.pydata.org/pandas-docs/stable/development/extending.html#define-original-properties" rel="nofollow noreferrer">_metadata original properties</a> are not pased to pyjanitor manipulation results</p> <p>Take the following MWE:</p> <pre class="lang-py prettyprint-override"><code>import pandas as ...
<python><pandas><pyjanitor>
2025-05-20 19:09:59
2
5,202
robertspierre
79,630,930
17,902,018
Unsloth doesn't find Llama.cpp to convert fine-tuned LLM to GGUF
<p>I am executing on an Azure VM this notebook from the Unsloth docs:</p> <p><a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3_(8B)-Ollama.ipynb" rel="nofollow noreferrer">https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3_(8B)-Ollama.ipynb</a></p> <...
<python><huggingface-transformers><large-language-model><fine-tuning><llamacpp>
2025-05-20 17:43:16
1
2,128
rikyeah
79,630,857
5,273,805
Runtime warning in sklearn KMeans
<p>I am running k-means using sklearn but has been getting runtime warning. Can you please explain what's happening? Below is a sample code for reproducibility:</p> <pre><code>import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.cluster import KMeans col1 = np.random.nor...
<python><scikit-learn><k-means>
2025-05-20 16:53:24
2
349
useryk
79,630,782
2,410,605
How to prevent a non-link web element from opening in a new tab
<p>I'm using Python Selenium to find an element, click it, and have the new page stay open in the same window instead of opening in a new tab. I'm trying to be careful with how I word this because I it's not an anchor or url, from what I can tell. The html is:</p> <pre><code>&lt;div class=&quot;prevent-select&quot;&gt;...
<python><selenium-webdriver><web-scraping>
2025-05-20 15:53:32
0
657
JimmyG
79,630,774
186,202
How to monitor temporal Workflows and Activities using Sentry?
<p>We are using Sentry to monitor our production bugs, and since we picked <a href="https://temporal.io/" rel="nofollow noreferrer">Temporal</a> to run our background tasks (workflows and activities) we don't have Sentry logging anymore.</p> <p>Is it possible to configure our worker to setup Sentry SDK and forward erro...
<python><exception><sentry><temporal><temporal-workflow>
2025-05-20 15:48:54
1
18,222
Natim
79,630,721
1,507,014
Why does VertexClustering.membership return a copy?
<p>Working with igraph in a project, we encounter serious timing issues. Running cProfile on the worst function, we realize that this code takes a lot of time:</p> <pre><code>[ partition.membership[x.index] if x.index &lt; len(partition.membership) else -1 for x in G.vs ] </code></pre> <p>where <code>G</code> is a <cod...
<python><igraph>
2025-05-20 15:11:23
1
5,006
Bentoy13
79,630,693
2,123,706
How to apply a pandas filter if the filter requirement is an element in a list
<p>I have a dataframe, and a list of potentially different filters.</p> <p>Is there a way to apply a filter that comes from a list so that the dataframe is filtered accordingly?</p> <p>MRE:</p> <p>In this example, the <code>df</code> is filtered based on the conditions set out in <code>filter_ls[0]</code>, ie, I want t...
<python><pandas><dataframe><list><filter>
2025-05-20 15:02:12
1
3,810
frank
79,630,643
2,097,820
Why composing a SQLAlchemy select doesn't work
<p>Consider following snippet:</p> <pre class="lang-py prettyprint-override"><code>stmt = db.select(Product).where(Product.id == 1) print(stmt) stmt = db.select(Product) stmt.where(Product.id == 1) print(stmt) </code></pre> <p>i'd expect to have equal stmt, but instead i got:</p> <pre><code>SELECT product.id, product....
<python><sqlalchemy><orm>
2025-05-20 14:24:43
1
2,617
Victor Aurélio
79,630,495
2,074,831
Typing sqlalchemy where clauses
<p>Following this doc:</p> <p><a href="https://docs.sqlalchemy.org/en/20/orm/extensions/mypy.html" rel="nofollow noreferrer">https://docs.sqlalchemy.org/en/20/orm/extensions/mypy.html</a></p> <p>I tried to type-check my <code>test.py</code> file:</p> <pre class="lang-py prettyprint-override"><code>from sqlalchemy impor...
<python><sqlalchemy><python-typing><mypy>
2025-05-20 13:00:47
1
3,974
sevan
79,630,444
1,310,032
How to get a moving average (or max) in time period using Django ORM
<p>I am trying to work out if it's possible/practical to use the Django ORM to get the highest value in an arbitrary timebox out of the database.</p> <p>Imagine a restaurant orders ingredients every day, we might have a simple model that looks like:</p> <pre><code>class Order(models.Model): date = models.DateField(...
<python><django><django-orm>
2025-05-20 12:29:13
1
1,199
David Downes
79,630,419
696,034
SeleniumBase usage
<p>We have a long-running process that creates RemoteWebDriver and works with Chrome browser; it is destroyed (.close() and .quit()) when needed.</p> <p>Now we're planning to migrate to SeleniumBase, and I cannot find a way to destroy it manually when needed because most (if not all) of examples follow the pattern of w...
<python><seleniumbase>
2025-05-20 12:16:24
1
7,316
Daniel Protopopov
79,630,126
3,213,204
Setting a persistent clipboard with multiple targets on X11
<h3>General overview</h3> <p>I am trying to set an image in clipboard into different linux’s <a href="https://man.archlinux.org/man/extra/xclip/xclip.1.en#t" rel="nofollow noreferrer">targets</a>. As example, depending of the context, the same image could be paste in png, jpg, or whatever else.</p> <h3>The problem</h3>...
<python><qt><pyqt><clipboard><x11>
2025-05-20 09:00:04
1
321
fauve
79,630,089
5,958,323
How to display a legend when plotting a GeoDataFrame
<p>I have a GeoDataFrame I want to plot. This works fine, however somehow I cannot easily plot its legend. I have tried a number of alternatives and checked solutions from googling and LLM, but I do not understand why this does not work.</p> <p>Code:</p> <pre class="lang-py prettyprint-override"><code>import geopandas ...
<python><matplotlib><geometry><legend><geopandas>
2025-05-20 08:34:01
1
9,379
Zorglub29
79,630,032
5,437,493
Defining a type that is both a Protocol and a Pydantic BaseModel
<p>I need to define a type that is both a <code>Protocol</code> and a <code>BaseModel</code>.</p> <p><strong>In detail:</strong><br /> The model <code>Foo</code> has a field <code>data</code> that can receive any model that has an <code>id</code> attribute ( let's call the type <code>HasId</code>).</p> <pre class="lang...
<python><python-typing><pydantic>
2025-05-20 08:00:33
0
839
Tom Gringauz
79,629,981
72,437
Issues Getting Ghibli-Style Image Output with Gemini API - What Am I Missing?
<p>I'm starting a venture in AI-powered image applications, and as a learning project, I'm developing a small app that transforms input images into <strong>Ghibli-style animation art</strong>.</p> <p>To experiment with different APIs, I tried the following models under the Gemini ecosystem:</p> <ol> <li><strong><code>g...
<python><artificial-intelligence><openai-api><google-gemini>
2025-05-20 07:33:02
1
42,256
Cheok Yan Cheng
79,629,963
15,358,800
How can I explode the string in sublists and fill into individual sublist
<p>I have a list like this.</p> <pre><code>[[&quot;Hi, this is Tesa form the sales departmet. Iam working here from&quot;],[&quot;&quot;],[&quot;&quot;]] </code></pre> <p>How can I explode this string inside the first sublist by preserving words by filling all sublists.Like,</p> <pre><code>[[&quot;Hi, this is Tesa.&quo...
<python><list>
2025-05-20 07:23:04
2
4,891
Bhargav
79,629,943
17,580,381
Unable to install spacy on MacOS 15.5 (M2) with Python 3.13.3
<p>Having created a new venv I am attempting to install spacy strictly in accordance with the <a href="https://spacy.io/usage#pip" rel="nofollow noreferrer">documentation</a></p> <p>Specifically:</p> <pre><code>pip install -U pip setuptools wheel pip install -U 'spacy[apple]' </code></pre> <p>This fails (huge error out...
<python><spacy>
2025-05-20 07:10:13
1
28,997
Ramrab
79,629,806
3,163,618
Sequence of function iterations
<p>Is there a way to abuse assignment expressions or functional tools to generate the sequence x, f(x), f(f(x)), ... in one line?</p> <p>Here are some contrived examples to demonstrate:</p> <pre><code>def iter(x, f, lim=10): for _ in range(lim): yield x x = f(x) iter(1, lambda x: (2*x)%99) </code><...
<python><iteration><sequence><python-assignment-expression>
2025-05-20 05:06:18
5
11,524
qwr
79,629,787
1,273,751
What is the currently recommended way to install Pytorch with CUDA enabled using conda?
<p>Pytorch official website used to have an installation option using conda (see printscreen in this answer: <a href="https://stackoverflow.com/a/51229368/1273751">https://stackoverflow.com/a/51229368/1273751</a>)</p> <p>But currently no <code>conda</code> option is available: <a href="https://i.sstatic.net/19ODdWY3.pn...
<python><pytorch><anaconda><conda>
2025-05-20 04:37:31
1
2,645
Homero Esmeraldo
79,629,693
1,719,931
Iterate over an object that is not an iterator
<p>I'm not sure why I can iterate over an object that is not an iterator?</p> <pre><code>&gt;&gt;&gt; import spacy &gt;&gt;&gt; nlp = spacy.load(&quot;en_core_web_sm&quot;) &gt;&gt;&gt; doc = nlp(&quot;Berlin looks like a nice city&quot;) &gt;...
<python><iterator>
2025-05-20 02:10:47
2
5,202
robertspierre
79,629,689
1,503,005
How to freeze Python build tools for repeatable builds?
<p>TL;DR: When <code>pip install</code> builds and installs wheels, how do I determine which versions of build tool packages (e.g. Cython) it used? How do I force it to use the same versions of those packages in the future? Besides <code>pip</code>, <code>wheel</code>, and <code>cython</code>, what packages do I need t...
<python><pip><build><cython><python-wheel>
2025-05-20 02:02:34
0
635
macdjord
79,629,626
10,069,542
Open edX Tutor Plugin: ModuleNotFoundError for custom OAuth2 backend despite proper installation
<p>I'm developing a custom Tutor plugin for Open edX that implements a WordPress OAuth2 authentication backend. Despite following the Tutor plugin development guidelines and ensuring proper installation (cf <a href="https://github.com/cookiecutter-openedx/edx-oauth2-wordpress-backend" rel="nofollow noreferrer">https://...
<python><wordpress><oauth><openedx>
2025-05-20 00:04:16
0
550
MMasmoudi
79,629,605
1,332,263
How to replace pack() with grid()
<p>The following code enables the status bar to remain at the bottom of the window and expand to fill the window when the window is resized. How can I replace pack() with grid() to do the same thing?</p> <pre><code>import tkinter as tk from tkinter import ttk colour='blue' class StatusBar(ttk.Frame): def __ini...
<python><tkinter><tkinter-layout>
2025-05-19 23:27:07
1
417
bob_the_bob
79,629,601
1,090,576
Why in python would blocking code delay a non-blocking sleep timer?
<p>In python, if I run the following code:</p> <pre><code>import asyncio import time from datetime import datetime async def delay(n: int, id: str): await asyncio.sleep(n) print(&quot;I am:&quot;, id, datetime.now()) return id async def main(): second = delay(1, &quot;second&quot;) first = delay...
<python><python-asyncio><blocking>
2025-05-19 23:20:13
1
3,390
Goblinlord
79,629,270
3,125,823
Vehicle records for auto parts application
<p>I'm trying to figure out how to create a vehicle filter for an auto parts application for a client. They want their customers to be able to filter by Year, Make, Model, Trim and Engine.</p> <p>We're using DRF so our thoughts were:</p> <p>Create a Django vehicles app with Year, Make, Model, Trim and Engine model clas...
<python><django-models><django-rest-framework><django-filter>
2025-05-19 18:14:27
0
1,958
user3125823
79,629,241
1,328,439
How to format a floating point number in engineering notation with zero before decimal dot
<p>I am trying to output the data from Python so that the output format matches the output from a FORTRAN code.</p> <p>When using <code>E</code> format specifier in Python, I get a non-zero leading digit before the decimal dot, i.e.</p> <pre><code>&gt;&gt;&gt; print(&quot;%13.5E&quot; % 3.1415926) 3.14159E+00 </code>...
<python>
2025-05-19 17:44:49
0
17,323
Dima Chubarov
79,629,166
8,357,778
Polars read_ndjson DynamoDB file high memory usage issue
<p>I'm trying to flatten a DynamoDB JSON file with Polars.</p> <p>My JSON file is 1GB, 100mo after compressing to gz but in memory when I read it, it uses 16GB.</p> <p>Because the data comes from DynamoDB, my columns can have multiple types. For example, 1 year ago it was a String, today it's a boolean.</p> <p>So I mad...
<python><json><dataframe><amazon-dynamodb><python-polars>
2025-05-19 16:46:16
0
319
Franck Cussac
79,629,132
14,542,688
ib_async TWS API only first order gets transmitted, remaining orders doesnt show on TWS
<p>Currently, I have a function that creates 3 orders:</p> <ol> <li>Market order to enter the stock</li> <li>Limit order for taking profit</li> <li>Stop order for stop loss</li> </ol> <p>However, on TWS only the first order is shown and auto transmitted to TWS through API. Furthermore, for each instance, only the very ...
<python><interactive-brokers><tws><ib-api><ib-insync>
2025-05-19 16:23:59
1
327
0xLasadie
79,629,009
3,213,204
Permutate two rows inside QTableWidget
<p>I have a simple <code>QTableWidget</code> with a unique relevant column (the other one still empty for the moment). And I try to permute two rows.</p> <p>I’ve made this method to my table:</p> <pre class="lang-py prettyprint-override"><code> def permuteRows(self, row1=0, row2=3): # saving the original con...
<python><qt><pyqt><qtablewidget><pyqt6>
2025-05-19 15:00:56
0
321
fauve
79,628,986
6,998,684
Cannot import: `from serpapi import GoogleSearch`
<p>I have this app in PyCharm (see screenshot). It won't run because of:</p> <blockquote> <p>ImportError: cannot import name 'GoogleSearch' from 'serpapi' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/serpapi/<strong>init</strong>.py) Process finished with exit code 1</p> </blockquote...
<python><pycharm><streamlit><venv>
2025-05-19 14:47:06
2
26,929
IgorGanapolsky
79,628,910
9,318,323
Improve code that finds nan values with a condition and removes them
<p>I have a dataframe where each column starts and finished with certain number of nan values. Somewhere in the middle of a column there is a continuous list of values. It can happen that a nan value &quot;interrupts&quot; the data. I want to iterate over each column, find such values and then remove the whole row.</p>...
<python><pandas><dataframe><numpy>
2025-05-19 14:11:43
2
354
Vitamin C
79,628,606
3,387,223
pyparsing LineStart not matching on indented line
<p>I couldn't find this anywhere. I'm using <code>pyparsing</code> on a project right now and I need to match keywords at the start of the line. I looked at the <code>LineStart</code> for this which is close but not quite the thing I need.</p> <p>E.g.</p> <pre class="lang-py prettyprint-override"><code>test_string = &q...
<python><pyparsing>
2025-05-19 10:58:36
1
4,956
CodeMonkey
79,628,526
12,978,930
How to make ty ignore a single line in a source file?
<p>I have been experimenting with Astral's type checker <a href="https://github.com/astral-sh/ty" rel="nofollow noreferrer">ty</a> recently. As its still pre-release, I run into false-positives from time to time and would like to explicitly tell ty to ignore these.</p> <p>How can this be done?</p>
<python><python-typing><ty>
2025-05-19 10:13:50
3
12,603
Hericks
79,628,462
11,251,373
Mock return value of CURL called from within Postgres stored procedure
<p>I have a Postgres stored procedure that uses API call made by CURL command from within itself to obtain CSV file from outer server:</p> <pre class="lang-sql prettyprint-override"><code>create procedure import_national_standards() language plpgsql as $$ BEGIN SET LOCAL statement_timeout = '60s'; DROP TAB...
<python><airflow><pytest>
2025-05-19 09:29:47
0
2,235
Aleksei Khatkevich
79,628,442
13,392,257
Is using mutex in my class redundant because of GIL?
<p>I have a class with two threads</p> <ol> <li>MainThread - solving tasks one by one(getting <code>self.cur_task_id</code>, and changing <code>self.cur_task_status</code>)</li> <li>Thread <code>self.report_status_thread</code> - read <code>self.cur_task_id, self.cur_task_status</code> and send values via http</li> </...
<python>
2025-05-19 09:17:09
1
1,708
mascai
79,628,273
10,258,072
How to use uv with Artifactory Python Package index
<p>How can I run <code>uv run myscript.py</code> using Artifactory as an alternative package index that needs authentication?</p>
<python><artifactory><uv>
2025-05-19 07:24:48
1
1,135
Boketto
79,628,093
219,153
Can this similarity measure between different size NumPy arrays be expressed entirely with NumPy API?
<p>This script:</p> <pre><code>import numpy as np from numpy.linalg import norm a = np.array([(1, 2, 3), (1, 4, 9), (2, 4, 4)]) b = np.array([(1, 3, 3), (1, 5, 9)]) r = sum([min(norm(a-e, ord=1, axis=1)) for e in b]) </code></pre> <p>computes a similarity measure <code>r</code> between different size NumPy arrays <cod...
<python><arrays><numpy><euclidean-distance>
2025-05-19 04:41:07
1
8,585
Paul Jurczak
79,627,995
1,639,359
Pandas Timedelta UnitChoices typing
<p>I am writing some python code using typehints and using mypy to check them. I have a variable <code>period</code> that I stated was a string. I later use that variable to instantiate a <code>pandas.Timedelta</code> object, setting the units to <code>period</code>. Here is a minimally reproducible example:</p> <pr...
<python><pandas><python-typing>
2025-05-19 02:08:09
1
7,874
Daniel Goldfarb
79,627,856
4,704,065
Iterate over a Dataframe column and find value based on condition
<p>I have a Dataframe with 2 columns. I want to compare the value of first column with some threshold for 5 iterations and if it exceeds that value, check the corresponding value of the another column</p> <p>DF: In the below example I need to check at what value of '<strong>Inst</strong>' where '<strong>Error</strong>'...
<python><pandas><dataframe>
2025-05-18 21:21:41
2
321
Kapil
79,627,795
1,332,263
Why does my approach to destroy window fail?
<p>I want the EXIT button to close the window but I get the following error:</p> <p>self.button=ttk.Button(self, text=' EXIT', command=app.exit).grid(column=0, row=0, sticky='ew') NameError: name 'app' is not defined. Did you mean: 'App'?</p> <p>Can someone tell me why and how to fix it please?</p> <pre><code>#!/usr/bi...
<python><python-3.x><tkinter>
2025-05-18 20:17:01
1
417
bob_the_bob
79,627,633
1,134,991
Python loop over nested generator with two variables, in one for loop
<p>Hell all. This is when using Python 3.<br> Say I have a tuple/list/generator, which elements are always are a two elements tuple.<br> A simple sample would be this: <code>( ( 1,2) (3,4) )</code><br> I want to loop (no nested loops), with two loop variables, akin to what is done when using <code>enumerate</code>.<br>...
<python><loops>
2025-05-18 16:37:43
1
3,129
user1134991
79,627,579
6,014,277
Spire.PDF for Python: PdfDocument.Close() gives attribute error
<p>Code (adapted from recipe book here: <a href="https://www.e-iceblue.com/Tutorials/Python/Spire.PDF-for-Python/Program-Guide/Conversion/Python-Convert-PDF-to-SVG.html#1" rel="nofollow noreferrer">https://www.e-iceblue.com/Tutorials/Python/Spire.PDF-for-Python/Program-Guide/Conversion/Python-Convert-PDF-to-SVG.html#1<...
<python><pdf><spire.pdf>
2025-05-18 15:29:25
0
754
Suzanne
79,627,492
13,727,105
Trainer is failing to load optimizer save state when resuming training
<h3>Intro to the problem</h3> <p>I am trying to train Llama-3.1 8B on an H100 but I keep running into the following error when trying to resume training</p> <pre><code>... File &quot;/home/jovyan/folder/training/.venv/lib/python3.10/site-packages/transformers/trainer.py&quot;, line 2405, in _inner_training_loop se...
<python><pytorch><huggingface-transformers><huggingface-trainer>
2025-05-18 13:35:13
0
369
Praanto
79,627,250
11,484,423
Python portable virtual environment
<p>I have a desktop and a laptop I use during commute. Both have the same OS.</p> <p>I want to work on a Python project on the desktop, sync files, then work on the laptop, sync files, work on the desktop and so on.</p> <p>What I tried:</p> <ul> <li>Bare system Python: it doesn't work, because something works with Pyth...
<python><portability><virtual-environment>
2025-05-18 08:09:09
3
670
05032 Mendicant Bias
79,627,095
9,779,999
UnslothGKDTrainer SyntaxError with Gemma 3: Missing unsloth_zoo Directory
<p>I'm trying to fine-tune Gemma 3 models (<code>egodfred/gemma-3-finetune-text_to_sql</code>, <code>nadmozg/gemma-3-12b-it-sql-finetuned</code>, <code>google/gemma-3-4b-it</code>) for SQL generation using Unsloth in a Conda environment, but I keep encountering a <code>SyntaxError</code> related to <code>UnslothGKDTrai...
<python><artificial-intelligence><gemma>
2025-05-18 01:47:07
0
1,669
yts61
79,627,075
10,461,632
python-oracledb fails when initializing thick mode in Docker
<p>I am trying to initialize python-oracledb in Thick Mode. It works on my Mac M1 Pro, but when I try to containerize my application with Docker, I get <code>DPI-1047: Cannot locate a 64-bit Oracle Client library: &quot;libclntsh.so: cannot open shared object file: No such file or directory&quot;</code>.</p> <p>I follo...
<python><oracle-database><docker><instantclient><python-oracledb>
2025-05-18 00:27:09
1
788
Simon1
79,627,051
12,184,608
type checking: assignment of merged dicts not compatible, even though individual dicts are
<p>I have a situation where I want to assign the union of two dicts (using |) to a typed dict variable. Each of the dicts on its own is assignment compatible, but assigning the result of the merge where at least one of the dicts is a literal results in MyPy and Pyright both reporting an error:</p> <pre class="lang-py p...
<python><python-typing>
2025-05-17 23:25:03
1
364
couteau
79,626,877
15,587,184
Pandas ThreadPoolExecutor with 16 workers cause missing or None DataFrames, while using 1 worker works for excel I/O Tasks
<p>I'm working on a real-world data processing pipeline where I process between 300–500 Excel files daily. Each file is read, wrangled into a pandas.DataFrame, and at the end all the resulting DataFrames are concatenated into one.</p> <p>When I use 1 worker (max_workers=1), everything works 100% fine, every time.</p> <...
<python><excel><multithreading>
2025-05-17 18:16:29
0
809
R_Student
79,626,781
9,549,068
pixi how to exit the venv shell in vscode?
<p>I'm using <strong>pixi</strong> for Python in vscode.</p> <p>In a normal terminal I can run <code>pixi shell</code> and <code>exit</code>, just like <code>.venv\Scripts\activate</code> &amp; <code>deactivate</code> to enter or leave the venv.</p> <p>But in vscode, I am forced to auto enter <code>pixi shell</code> mo...
<python><visual-studio-code><python-venv><pixi-package-manager>
2025-05-17 16:56:24
0
1,595
Nor.Z
79,626,632
459,745
Calling asynchronous function from synchronous function inside Jupyter
<p>In our project, a number of functions come in 2 flavors: asynchronous and synchronous. We write the asynchronous version and provide a <code>runa()</code> wrapper around the <code>asyncio.run()</code> function:</p> <pre><code>async def read_sensor_async(): print(&quot;Reading sensor...&quot;) # Actual code ...
<python><jupyter-notebook><python-asyncio>
2025-05-17 14:17:32
1
41,381
Hai Vu
79,626,566
8,126,390
VS Code python extension seeing some not all Django class
<p>Simple problem: the Python extension of VS Code is not seeing a Django class, while all other classes in same file are presented. Restarting, disabling/enabling, switch to pre-release for the extension doesn't change anything. Confirmed it was the extension as disabling it removes all import objects.</p> <p><em>edit...
<python><django><visual-studio-code>
2025-05-17 13:15:41
0
740
Brian
79,626,509
13,392,257
How to improve selenium script so that the captcha does not appear
<p>My aim is to fetch search-engine results (urls) from yandex.ru</p> <p>I am running this this selenium script. The script is working fine on my PC, but on the server I see sophisticated captch (see Image below)</p> <p>How to improve the script so that the captcha does not appear</p> <pre><code>import undetected_chrom...
<python><selenium-webdriver><undetected-chromedriver>
2025-05-17 12:12:10
2
1,708
mascai
79,626,384
6,114,832
SCIPY BPoly.from_derivatives compared with numpy
<p>I implemented this comparison between numpy and scipy for doing the same function interpolation. The results show how numpy crushes scipy.</p> <pre><code>Python version: 3.11.7 NumPy version: 2.1.3 SciPy version: 1.15.2 Custom NumPy interpolation matches SciPy BPoly for 10 000 points. SciPy coeff time: 0.218046 s Sc...
<python><numpy><performance><scipy>
2025-05-17 09:35:17
2
1,117
Stefan Karlsson
79,626,285
7,791,963
How to make robot framework SSHLibrary not call logger.log_background_messages() on close unless in main thread?
<p>I am in my keyword running some parallel tasks using concurrent.futures and using robotbackgroundlogger to log the messages. After all threads are finished I run <code>logger.log_background_messages()</code> in the main thread since it only allows running it in main thread.</p> <p>The problem is that SSHLibrary() au...
<python><robotframework><robotframework-sshlibrary>
2025-05-17 07:19:22
0
697
Kspr