Questions tagged [python]
Python is a dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Note that Python 2 reached end-of-life on January 1st, 2020. For version-specific Python questions, add the version tag (e.g. [python-3.x] or [python-3.9]). When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.
python
2,203,211
questions
0
votes
0
answers
2
views
Matrix multiplication on Python to find a polynomial
I wish to find a method to multiply matrices (with other matrices and vectors) whose elements contain polynomial expressions and to obtain the final results in polynomial format.
I have a 10 by 10 ...
0
votes
1
answer
16
views
Pip version trouble in pycharm
So, I want to start a new project in pycharm and it always starts with an outdated version of pip and I have to do the upgrade. It's not really a problem for a project, but it's getting annoying for ...
2
votes
2
answers
41
views
How to print palindrome pattern without using any string method
I am currently stuck not getting how do i need to print the below pattern without using any string method or any string properties and not even any thing which direct or indirectly associated with ...
1
vote
1
answer
16
views
Python: Selenium's driver.find_element(...) cant find the button im looking for:
This code is supposed to click a button (accept the cookies) and then take a screenshot of the page. It takes the screenshot of the right element with the right height & width, but it does not ...
2
votes
2
answers
6k
views
get current system serial number in python
I am looking for a way to get system serial number using python.
Below is the command to get serial number using command prompt:
wmic bios get serialnumber
Is there any python library to get the same?...
0
votes
1
answer
17
views
How to get username for top posts for a certain keyword using selenium in python
Trying to get to the top posts for a keyword on instagram and capture their username and save it into a csv. Since the username is only displayed when the post is clicked I am unable to find the ...
-1
votes
0
answers
9
views
how to convert custom dataset polygon annotation format saved in .xml format. I need to convert .xml to coco json format. please find below format
<?xml version="1.0" encoding="utf-8"?>
<annotations>
<version>1.1</version>
<meta>
<job>
<id>1015773</id>
<...
0
votes
0
answers
4
views
Multithreading TFRecord writing stops abruptly on kaggle notebook
I'm reaching out for some help regarding multithreading for TFRecord writing in Kaggle notebooks. I'm currently working on the VGGFace2 dataset and aiming to convert image pairs into TFRecords for ...
0
votes
0
answers
7
views
'django-admin' is not recognized as an internal or external command, operable program or batch file
Yesterday I installed Python and added it to PATH. Then I created a virtual environment using virtualenv.
I then activated the environment and pip-installed django (using pip install django) and ...
1
vote
2
answers
349
views
Getting a 422 error response when calling FastAPI backend with a GET request using Axios HTTP Client
I'm trying to make a GET request from my Vue3 client (using axios JavaScript HTTP client) to a FastAPI server and I´m getting a 422 unprocessable entity error response. As I understand, this kind of ...
0
votes
1
answer
18
views
SignalIntegrity cannot import name 'math' from 'numpy'
I can not launch the SignalIntegrityApp GUI application
I carefully followed the instructions in the website:https://github.com/Nubis-Communications/SignalIntegrity/wiki/Installation
However, when I ...
0
votes
2
answers
368
views
How to catch or process RequestValidationError exceptions differently in a FastAPI middleware?
How to correctly combine RequestValidationError exception handlers, such as :
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
response = ...
1
vote
1
answer
205
views
422 Unprocessible Entity error when sending List of Form data through Swagger UI docs using FastAPI
I created an API, using FastAPI, for transcoding video files like adaptive bitrate of youtube. Currently, I am trying to set resolution values for each file. But, whenever I am passing multiple ...
0
votes
1
answer
29
views
SQLAlchemy not executing update unless walking through code with debugger
I am genuinely baffled by the behavior I'm seeing so I'm hoping someone can shed some light onto what's going on here. Basically, I have a web app using FastAPI and SQLAlchemy in the back end that ...
-1
votes
1
answer
71
views
Python Function Member of Class, Class as Parameter. How To, or Work Around [duplicate]
I have a Python class that represents a matix of integers. The Matrix class has a function that can cross tabulate itself (? better word), with another Matrix passed to its cross tabulate function as ...
1
vote
1
answer
36
views
Trouble Capturing All Tick Data with Concurrent.futures in Python [closed]
I am developing a program to insert tick-level data for 300+ stocks received in a webstream dictionary format from a broker API. I successfully have a version of the program running without concurrent....
5
votes
2
answers
4k
views
In python, how to call a function with an argument on a click event
I created the code below, but when I click on the click me button I get the following error message:
TypeError: 'mpfr' object is not callable
Would someone know what is wrong with the code?
import ...
1
vote
0
answers
12
views
Fetch likes from Instagram reels
In an attempt to study Benfords law, I'm trying to get a list of the likes on recommendet Instagram Reels. So the plan is simply to open Reels, fetch the Like Count, swipe to the next Reel and repeat ...
2
votes
1
answer
5k
views
why mock.patch doesn't work while trying to mock a function
The structure of the project is
main.py
from src.tools.tool_a import fun
def main_fun():
fun()
tools_a.py
def fun():
raise Exception('')
test_fun.py
from unittest.mock import patch
from ...
2
votes
2
answers
841
views
How can add multiple Options in Selenium with Python
I want to add those options in Python, one for installing an extension and one is for detach browser.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium....
0
votes
1
answer
28
views
Python Pandas how to plot multiple colmuns on x axis?
I have a dataframe that looks like this:
import pandas as pd
data = {'Floor': [1, 2, 3, 4], 'IDR 1': [15, 6, 7, 9], 'IDR 2': [36, 12, 78, 23]}
df = pd.DataFrame(data)
df:
Floor IDR 1 IDR 2
0 ...
0
votes
0
answers
12
views
I'm trying to build a nand2tetris assembler but the ply.lex library in python keep breaking my assembly instructions to different lines
the first thought I had was that I didn't manage to handle the new line character properly because it keeps throwing the new line character "\n" whenever I try to append the instructions for ...
0
votes
0
answers
6
views
export an openhermer model to onnx
i am trying to export teknium/OpenHermes-2.5-Mistral-7B to ONNX,
this is my code :
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import onnx
model_name = "teknium/...
0
votes
0
answers
10
views
How to remove a widget from a screen
I'm trying to make a screen with textinput a btn and a recycling view.
The btn add to the recycling view a card with the text of the textinput, each card has a trash-bin button to remove the card and ...
0
votes
0
answers
5
views
photoshop-python-api says that I may not have photoshop installed correctly
I'm trying to write code that will take data from an excel spreadsheet and fit it into certain layers in a psd file.Here is my code:
import pandas as pd
from photoshop import Session
import os
def ...
-1
votes
0
answers
23
views
error with to_list() function on first run (python)
I'm working on a sentiment analysis project related to gemini on google co.lab. one of the steps is where I isolate a column containing ios app reviews, transforming it into a list and cleaning it of ...
1
vote
1
answer
49
views
Adjusting colormaps for geoplotting
I draw some geoplots using cartopy. Using Two Slope Normalisation and "RdBu_r" colormap to plot air temperature field.
color_map = 'RdBu_r'
fig = plt.figure(figsize=(16, 12))
ax = plt.axes(...
0
votes
2
answers
28
views
redis.exceptions.ResponseError: unknown command 'JSON.SET' with redis-py
No matter what I try, I keep getting this error message.
import redis
r = redis.Redis(host='127.0.0.1', port=6379)
r.ping() # -> True
r.json().set('test', '.', '{"foo": "bar"}'...
0
votes
0
answers
13
views
Yes/No Popup on PySimpleGUI
How do I use yes/no popups on PySimpleGUI? I've searched everywhere, but the answers just aren't clear on this.
At the moment, I am just trying to make a simple yes/no program so I can get my head ...
2
votes
2
answers
57
views
Python/Regex: Finding a specific pattern to update and then placing it back in the original text
I have a long file containing thousands of lines and a couple of samples are shown below:
\begin{align*}
H_0 \amp : \mu_1 = \mu_2 = \mu_3 = \mu_4 = \mu_5 \\
H_1 \amp : \text{Some text} \\
H_2 \...
0
votes
2
answers
43
views
how to make my program loop back to a specific line in python
I'm trying to make this code go back to the top of the program instead of ending at the printed string after the first if statement.
num_1 = (input("Please enter a whole number: "))
num_2 = (...
-1
votes
0
answers
20
views
Django hosted on Render - Media Files/template vars
I've got a Django app that stores its static and media files in an AWS S3 bucket. Retrieval, usage and storage of these files work fine locally. The issue is, when accessing through the live site ...
1
vote
0
answers
9
views
running monte carlo simulation on AWS EC2 instance
I would like to ask a general advice how to implement a monte carlo simulation on AWS remote server
My monte carlo simulation is a python script using other python scripts for functions, and outputs ...
0
votes
1
answer
27
views
Using scenedetect to spot subtle cut edits in a video?
I'm trying to use the Scenedetect Python package to detect subtle cuts in a video. For example, I'm looking at this video:
https://www.youtube.com/watch?v=fNb_-Tmxq8Q
I have downloaded the video and ...
0
votes
0
answers
27
views
How do you compile OpenCV with Python with CUDA Support on Rocky Linux 9?
I am trying to build opencv-python per the official instructions with support for CUDA so I can run SIFT. When I try to build with pip wheel . --verbose I get:
-- Configuring incomplete, errors ...
0
votes
0
answers
9
views
Blender Robotic control Python code giving wrong angles?
I made a code for my ESP32 to control my robotic arm ( 5 Axes ; 5 steppermotors ) when it gets coordinates through the serialport like e.g.: "1000, 1000, 1000, 1000, 1000.
Then, I have code in ...
0
votes
0
answers
9
views
Plotly Express: Remove Trendline from Marginal Distribution Figures
I'm looking for a "clean" way to remove the trendline from the marginal-distribution subplot created using plotly-express. I know it's a bit unclear, so please look at the following example:
...
2
votes
1
answer
6k
views
Statsmodels OLS Regression: Log-likelihood, uses and interpretation
I'm using python's statsmodels package to do linear regressions. Among the output of R^2, p, etc there is also "log-likelihood". In the docs this is described as "The value of the likelihood function ...
0
votes
0
answers
23
views
How to make a subprogram return to the main program
Im creating a rock paper scissors game which consists of a subprogram containing the single player game, which is stored on a different file and imported to the main program which runs it. In the ...
0
votes
0
answers
20
views
How to solve the following problem for method where we have other
Question:
A point represents a location in a two-dimensional space, characterized by its x and y coordinates.
Here is the partially completed Point class that you will be working with:
class Point:
...
0
votes
2
answers
111
views
How to extract all h2 texts from some URLs and store to CSV?
Need to extract all h2 text from some links and I tried it by using BeautifulSoup, but it didn't worked.
I also want to output them to CSV
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import ...
0
votes
3
answers
2k
views
How to easily switch to another SVN branch in PyCharm Django Project
I have a PyCharm Django project, versioned with SVN. Project itself been created via "Checkout from version control" function, and root of a project is a root of repository, so it includes trunk and ...
0
votes
0
answers
30
views
How to pass list of integers as arguments for django's raw SQL, without formatting string [duplicate]
I'm struggling to figure out how to pass list of integer as arguments for Django's raw SQL without using f-string method.
I have tried a simple method of
def raw_query(self) -> str:
return &...
0
votes
0
answers
7
views
How to Log in to a Discord Bot with SOCKS5 Proxy Authentication
I am trying to log in to a Discord bot using a SOCKS5 proxy with authentication. Here is the simple code I am using to log in without the proxy:
import discord
TOKEN = "YOUR_BOT_TOKEN"
...
0
votes
0
answers
48
views
How to create a new list[list[str]] column based on another list[str] column without iterating over rows
(Please edit the title if you find a more suiting one)
I have following dataframe that contains grouped records:
Table 1
┌──────────────────────────┬─────────────────┬─────────────┐
│ str_id ...
3
votes
3
answers
4k
views
Python: "Module Not Found Error" in Virtual environment
I'm a newbie with Python and been trying to install modules using pip unsuccessfully in my small project.
Following advice online, I've created my own virtual environment and imported my first module ...
0
votes
3
answers
33
views
Slice row out of CSV file...either using python or jsonata
I am using the C2Intel Feeds to find specific observables and when I do, I'd like to extract/slice out the row.
Example:
https://raw.githubusercontent.com/drb-ra/C2IntelFeeds/master/feeds/...
1
vote
0
answers
7
views
response error when working on jupyter notebook for the purpose of extracting data on tweeter
tweets = []
try:
response_json = connect_to_endpoint(search_url, headers, params)
print("Response received successfully.")
except Exception as e:
print(f"An error occurred: ...
0
votes
0
answers
14
views
How to restructure this netCDF?
I have downloaded a netCDF-dataset which I read in with xarray, but is has a relatively complex structure and I'm not able to grasp how to bring it in the general format as (time, lat, lon), so that I ...
0
votes
0
answers
10
views
Experiencing an error when trying to import from a diffrent directory
i am trying to import a function from another file
a/b/c.py
a/1/2.py
i wanted to import a funciton from c.py in 2.py
sys.path.insert(1, '/path/to/c/py/a/b/c')
from c import function1, function2
i ...