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. Please note that Python 2 is officially out of support as of 2020-01-01. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

Error loading MySQLdb module. Did you install mysqlclient?

File "C:\Users\bhavika\demo\Lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module> raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Error ...
Prem patel's user avatar
0 votes
0 answers
11 views

TypeError: expected string or bytes-like object on re.sub()

I have a dataframe which contains a column named 'text'. dtype is a string object. I think because it is too long to store as string and has been converted to object automatically when I load from csv....
siucat's user avatar
  • 33
0 votes
0 answers
9 views

Looking for a Waypoint-Limited Alternative to the Google Maps Directions API

I'm working on a project right now that requires routing with several waypoints. I have, however, come upon the Google Maps Directions API's limit on the quantity of waypoints that can be included in ...
snippetWizard's user avatar
0 votes
0 answers
7 views

Cannot uninstall open3d in ubuntu20.04 by using pip uninstall

im trying to uninstall open3d pkg from my ubuntu 20.04 but it didn't work well by using pip uninstall open3d ERROR: Exception: Traceback (most recent call last): File "/usr/lib/python3.8/shutil....
Tharit Sinsunthorn's user avatar
0 votes
0 answers
13 views

Error loading ASGI app. Could not import module "main"

Please anyone help me in executing this project Error loading ASGI app. Could not import module "main". [I an working on chatbot song recommender system project and I am getting these ...
Rakesh's user avatar
  • 1
-1 votes
0 answers
15 views

Is there a way i can use python to detect a “shoulder of a cantilever” and output its coordinates?

I have a bunch of photos of microcantilevers under a microscope. I need to find a solution using python to accurately detect this “shoulder” region of the microscope and output the specific ...
Joy Merwin's user avatar
-1 votes
0 answers
7 views

ImportError: No module named temp while calling Python code from Java

I'm trying to call Python code from Java. Here is my Java code. try (PythonInterpreter pyInterp = new PythonInterpreter()) { pyInterp.exec("from temp import add"); pyInterp....
Datta Dhonde's user avatar
0 votes
0 answers
10 views

Is there a conception of state across multiple chains in langchain?

How do I ensure the variable name from chain1 persists in chain2? Is there a conception of maintaining state in langchain? from langchain.prompts import PromptTemplate from langchain.schema import ...
atticus-finch-100's user avatar
0 votes
0 answers
17 views

What could be causing "collect2.exe: error: ld returned 1 exit status" when manually compiling C++ with pybind11?

I have a C++ script which compiles with pybind11 to create a file that python can use. I got it to work on my Ubuntu machine with python 3.8, but when I try to do it on my Windows machine it fails ...
alvrm's user avatar
  • 331
-4 votes
0 answers
18 views

How to optimize Recursive Fibonacci in Python [duplicate]

I'm working on implementing the Fibonacci sequence in Python using a recursive approach. While the basic implementation is straightforward, I'm interested in optimizing the code for better performance....
HTSMX's user avatar
  • 1
0 votes
0 answers
13 views

How to wrap a Python executable to call another Python executable and use all of the argparse options?

I have the following Python executable called fastq_preprocessor.py in my path. I'd like to create a wrapper called fastq_preprocessor that calls fastq_preprocessor.py which is in the same directory ...
O.rka's user avatar
  • 30.2k
0 votes
0 answers
21 views

Is there a way to simplify this code? (Python) [closed]

So I just started coding python and learning all the syntax. I'm trying to create a rock paper scissors game in python. I created it from scratch and imported the random and termcolor module. I tested ...
AwesomeAnt123's user avatar
0 votes
0 answers
10 views

python - genfromtxt not able to load the file

My question is very basic i m new to python .I am trying to load data from text file import numpy as np data = np.genfromtxt('rawdata.txt', delimiter=",") but its giving me error data = np....
code ny's user avatar
0 votes
0 answers
7 views

Python Kivy collide_point() not recognizing when mouse cursor hovers over widget

In Kivy I've tried to create a button or widget that changes color/text/cursor-type/etc when the mouse cursor hovers over it. Per suggestions online I used the collide_point() method. But I'm running ...
mishaeel's user avatar
-3 votes
0 answers
22 views

Switching Between Execution Environments, Python

So I am trying to run tests on an open source repo and when I run pytest using a terminal which has sourced another virtual environment, I am getting module import errors but when I install those same ...
wannabecsguy2's user avatar
-2 votes
0 answers
17 views

Does anyone know what this error means? <function scrape_sayings at 0x6d316e0900> [closed]

import requests from bs4 import BeautifulSoup import random import datetime import os def scrape_sayings(): # Send a GET request to the website response=requests.get`your text`("https://...
Michael Bishop's user avatar
0 votes
0 answers
5 views

Bluetooth Comm API from bluedot | OBD and Raspberry PI Errors

I am building an OBD Raspberry PI car dashboard and I've been struggling to get the adapter to connect and send info. I recently learned that the rfcomm support was dropped years ago by bluez and was ...
Soham Deshpande's user avatar
0 votes
0 answers
5 views

RobertaTokenizer encoding sentences to the same value

I'm trying to encode a list of profiles so that I can later feed them into a Roberta model. The profiles are basically sentences that follow the same structure. Basically, one profile is as follows: ...
Jesper Ezra's user avatar
-1 votes
0 answers
27 views

Complex Python Module Imports

I have a directory like this: my_project/ ├── module1_dir/ │ ├── __init__.py │ └── module1.py ├── module2_dir/ │ ├── __init__.py │ └── module2.py ├── __init__.py notebook_dir1/ ├── ...
Kevin Li's user avatar
0 votes
0 answers
10 views

Timeseries with Min/Max for three series as a function of Location and toggle to change plot based on Location

I have some test data that I need to do some simple analysis. I have to calculate yearly min, mean and max for three different benchmarks (Level 1, 2 and 3) as a function of location (from 2020 to ...
MC23's user avatar
  • 1
0 votes
0 answers
4 views

Reading multiple videos in parallel with PySpark

I need to write a PySpark script in order to read in multiple video from mp4 files parallelly and then process it in PySpark. (These 4 video stream represent multiple RTSP video stream which I will ...
Lăng Khoa's user avatar
0 votes
0 answers
6 views

Creating Grid Graphics Tkinter

I'm doing a project where I create a counter clockwise spiral of natural numbers with rectangles. An example of this is shown below: spiral natural numbers Instead of colors with numbers in them, ...
MadelineJaccon's user avatar
0 votes
0 answers
3 views

Streamlit: Selection base on the precedented selection not working in form

With the code without a submit form, it works as intended. The multiselect will then open “Sector” multiselect and if “Others” is selected, it will open the text input for user to key in. However, it ...
bkcollection's user avatar
0 votes
0 answers
7 views

Raspberry Pi Pandas/Numpy ImportError: Unable to import required dependencies: import numpy from source directory

I was doing import pandas as pd and immediately got the ImportError. Error message: Traceback (most recent call last): File "/home/projects/.../pm_venv/pd_test.py", line 1, in <module&...
yhc0712's user avatar
-1 votes
2 answers
35 views

Is It Bad Practice to Alter Code in Order to Satisfy The Linter

I use neovim and use the pyright linter through mason-lspconfig in order to statically type check my code. I write many type hints; here's an example: def example(user_input: str) -> None: ...
8SIXSector's user avatar
0 votes
0 answers
31 views

Migrating a library to SQLAlchemy 2.0, compliance tests failing with AttributeError

I am currently trying to migrate a library from SQLAlchemy 1.4 to 2.0, I have made the necessary changes following the migration guide, however when I try to test my changes with SQLAlchemy's dialect-...
kiraksi's user avatar
0 votes
0 answers
46 views

Unexpected angle value

I have a vector A with coordinates (-51.85,-2.38,-0.93). The normal vector at point A(lets call it Na) is (0,0,1). I want to calculate the angle between the position vector A and the normal vector Na. ...
Tariq Islam's user avatar
0 votes
0 answers
9 views

How to use websockets.broadcast() in while True loop

In this function, I want to get video frames and predict them, then broadcast predicted result to all subscribers, but when I run this function, clients can't receive result. Because code don't return ...
Ian Shih's user avatar
0 votes
0 answers
12 views

Python Pandas append to concat within a custom function with loops? [duplicate]

So I learned that my version of Python doesn't take append, which was in the original code: def getDataForDateRange(date_Index_New, rows): WeeklyStockDataRows = pd.DataFrame() for I in ...
Dun's user avatar
  • 101
0 votes
0 answers
5 views

Can not connect to localhost from other device on same network even though turning off firewall

I am trying to Running Flask server with windows 10 pro. As google said I run the server on 127.0.0.1:5000 and found my ip (192.168.2.35) so I connected same network via wifi with my mobile phone then ...
ohyes's user avatar
  • 1
1 vote
1 answer
16 views

Dynamically split columns in pandas dataframe by the same character

I have about a bunch columns that need to be split on a colon (:). Is there a way I can do that without having to specify every single split. Sometimes the record has 2 colons and sometimes 3. Example ...
Bama's user avatar
  • 11
0 votes
0 answers
6 views

How do I get Qlistview to include all the search details for pdf hits in QPdfSearchModel Class for python like it does in the documentation

When I do a pdf search using the QPdfsearchmodel class my model only seems to include the word I searched for and context before/context after: However, in the documentation there is also a listing ...
ScottyCov's user avatar
0 votes
1 answer
22 views

404 error when try to import files in html

I have a project in pycharm which use app.py to call the page1 and page2_test html file. My project structure is like this: Project structure All the csv and jpg files are in the data folder. My app....
Alice's user avatar
  • 1
0 votes
1 answer
22 views

how to make automation google search in python

i have a 100 list in spreadsheet that content many keywords. i want to search in google automatically. i have try this code but does not work. what should i do ? from selenium import webdriver # ...
iyya's user avatar
  • 45
1 vote
1 answer
24 views

How to run t-test on multiple pandas columns

I want to write a code (with few lines) that runs t-test on Product and Purchase_cost,warranty_years and service_cost at the same time. # dataset import pandas as pd from scipy.stats import ...
nasa313's user avatar
  • 278
0 votes
0 answers
3 views

Control duplication of legend items in Python Plotly.express

I am using plotly.express to produce a figure with 3 subplots. The legend repeats for each subplot, so I have 3 legend listings (one for each subplot) for each item. All operate together when I click ...
WillH's user avatar
  • 281
0 votes
0 answers
9 views

How to display value of another fields of related field in Odoo form views

is that possible to display value of another fields of related field? For example, by default, in Sale Order, the displayed value of partner_id is the value of partner_id.name .. how if I want to ...
Jessie M's user avatar
  • 508
0 votes
0 answers
17 views

Nevertheless input different 'data.csv' |Why RNN result's always linear?

It's my forecast code import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.models import Sequential from ...
tuk_shin19's user avatar
0 votes
0 answers
10 views

How to use Merge Into in Databricks (PySpark) given the source has null values to insert into a defined target schema (delta table)

Background: I am building a json parser that can take in any format of json and write it to a delta table with a schema that can update based on new data / new columns that come in. I am trying to ...
dataengineeringhelp's user avatar
0 votes
1 answer
26 views

Simon Says Python Tkinter Game

I need to code a Simon Says game using tkinter . The CPU generate random # of first moves and the CPU image changes to the generated listed. The user then uses the button on the GUI window and the ...
Kawinthida Haase's user avatar
0 votes
0 answers
17 views

plotly express strip plot with temporal data

Plotly express strip plot does not separate the points by color when temporal data is used on the x-axis. Set up some data with random groups and status (which will be the color of points in our plot) ...
LogZ's user avatar
  • 154
0 votes
1 answer
26 views

I'm trying to write a simple Python script that calculates the square of a number, but I keep getting a TypeError: 'int' object is not callable error

I expected the output to be 25, but I'm getting an error instead. I've tried changing the variable name and using a different approach, but I still can't figure out the issue. Can someone help me ...
JITHENDRA's user avatar
0 votes
0 answers
31 views

ADF: Selecting from a json object that has attributes and values pivoted

One of the oracle REST APIs response is like below: `{ "attributeId": 300000000227671, "attributeName": "BUSINESS_UNIT&...
Advaitha's user avatar
-1 votes
0 answers
17 views

Flask preserve nav selections after a reload, post or get response

I'm working on a typical Flask dashboard app using a sidebar nav tree. templates in jinja. I'd like to retain the sidebar selection state after a reload, post or get response. Sense the flask re-...
Todd Albiston's user avatar
1 vote
0 answers
29 views

Why a print modifies a pairwise? [duplicate]

I have the following code import pandas as pd import itertools as it data={ 'X': [1, 2, 3, 4, 5,6,7,8,9,10], 'Y': [5, 4, 3, 2, 1,2,3,4,5,5], 'Cat':["cat","dog",None,...
KansaiRobot's user avatar
  • 7,946
0 votes
1 answer
32 views

How can I link lists of different sizes with numpy or pandas?

I have a list of 7 python elements (it will always be 7 elements because they correspond to the 7 days of the week) For example: values = [0.10870379696407702, 0.10279934722899532, 0.07997459688639645,...
Diego L's user avatar
  • 253
-1 votes
1 answer
37 views

python Class name not define

this is the model.pythis is the model.py this is the model.pythis is the model.py ''' from django.db import models from django.contrib.auth.models import AbstractUser Create your models here. class ...
Jirus Jai Camacho's user avatar
0 votes
0 answers
13 views

Sqlite3 not commiting changes to my database

import sqlite3 from datetime import datetime, timedelta def update_expiration_date(user_id, day): conn = sqlite3.connect('instance/users.db') cursor = conn.cursor() new_expiration_date = ...
AJA SMBAT's user avatar
0 votes
0 answers
10 views

Defining custom protocols in Scapy - field length

I've found previous stackoverflow questions that are relevant to my question but I don't believe I followed the suggestions. I want to define a 16 byte field and seeing references to how Scapy uses ...
k_charles's user avatar
0 votes
0 answers
14 views

The efficiency between ProcessPoolExecutor and ThreadPoolExecutor

Efficient summation of a list involves parallelizing the addition process while maintaining the order. The objective is to create a hierarchical structure resembling a tree, where adjacent nodes are ...
Wei-jia Huang's user avatar

1
2 3 4 5
43498