Category "python-3.x"

Auto-enter a value when prompted from a Python Script

Say I have access to a Python script (of which I didn't create) that prompts for a user input and then runs some processing tasks based off the input before out

ImportError: cannot import name 'Message' from partially initialized module 'pyrogram.types' can not import it

I am using pyrogram in a program but when i run the program it gives import error i uninstalled and reinstalled it but the problem is still there. I am not able

python and BaseHTTPRequestHandler : add an empty favicon in the header of the generated page

On python 3.8, I created a minimalist python server for my students with BaseHTTPRequestHandler and HTTPServer from the module http.server When I go to the url

Creating new pandas columns from substrings in a list

I have data in a csv called 'Features' which is of this form: 0 [Shops: Close by, Passing trade: Yes] 1 [Lift: Yes, No of Bedrooms: 1, Bedroom 1 Dims:

Input() function works inconsistently, python 3.8.10, spyder 5.3.0, IPython 7.32.0

The code print("Some text") integer=int(input("Enter an integer: ")) is expected to print "Some text\nEnter an integer: " and read the users input, but some of

Crop colour image according to OTSU threshold

I have a colour image which I have sucessfully applied the OTSU thresholding method on its greyscale form to obtain the outline of the biscuit: Original Colour

Instruct WebApp using Django to run the code locally and return results

I am a newbie to web development and python scripts. I am learning to host python scripts using Django. I would like to know how to instruct Django to run the s

comment SQL query with variables in python

I'm working with Cloud Function. I have the following query working correctly: # this is working q = """ SELECT col1, col2 FROM `my_table` WHER

How to import other Python files

I have this file, abc.py: def asb(): print("Hello, ") def xyz(): print("World!") In my main.py file, from abc import asb from abc import xyz I want

Standard Deviation coming NaN in Pyspark rolling window

I have a dataset with 4 sensor values, 'volt', 'pressure', 'rotate' and 'vibration'. For these sensor values I am calculating rolling mean and rolling standard

How to get rid of Django security vulnerabilities warning signs in terminal

I have a simple Django project with a PostgreSQL backend and I can't seem to get rid of the Django security vulnerabilities warning signs on my terminal. Settin

How do you print accented characters?

I want to write a program that takes text from a file and prints the selected lines. When printing a word containing an accented character like "ó", I ge

Python Plotly image how to save image to a iobuffer and read it back

Python Matplotlib image is saved like : img = io.BytesIO() plt.savefig(img, format='png') img.seek(0) encoded = base64.b64encode(img.getvalue()) but for plotly

How to convert a cupy.ndarray to a scalar?

I'm working with CuPy at the moment. I've noticed something that seems to be a bug, but I'm not sure. I've noticed that if I use certain math functions, they re

Datashader integration for polygons in plotly mapbox

I'm using plotly's Scattermapbox to overlay a map with a shaded image of polygons created by datashader's shade function (based on https://plotly.com/python/dat

Run a UNIX script to use different versions of python

I have a UNIX script which is used to initialize the environment and properties of the project. It uses python. I had to refer the path. This will be used as a

MIME type ('text/html') not a supported stylesheet MIME type, and strict MIME checking is enabled in Django Web Application

I am hosting a Django web application on a cPanel web hosting server. I have the application up and running however it is not applying the CSS stylesheets to my

I want to end the while loop in python when both the conditions are false but it stops when only one condition is false

Here's my code, the purpose is to generate an array with 10 randomly generated 0's and 10 randomly generated 1's. While loops stops working when 'a' is equal to

How to typehint the return value of a function that takes other functions

I have a function that accepts other functions, and would like to type-hint the return value of this "wrapper" function. The function is similar to this below,

How to typehint the return value of a function that takes other functions

I have a function that accepts other functions, and would like to type-hint the return value of this "wrapper" function. The function is similar to this below,