Category "python-3.x"

pytest (or unittest) not working when a source file has a dependency

I'm not sure why this is so difficult to get going, but I'm new to Python and I'm trying to get any unit test framework to run tests, but if I test a file that

Copying from a range of cells with openpyxl, Error: Colors must be aRGB hex values

I am copying a range of cells with openpyxl from one workbook to another with the following code: import openpyxl import os #Current path path = os.path.dirnam

I can't locate my python path (but able to locate python3 path)

I'm currently using Mac Pro and downloaded python through brew install python for the latest version (though it downloaded 3.9.12 instead of 3.10.x). Also, whil

Can't fetch user info from Keycloak using Python on docker compose

I need to run, from docker compose, three containers: a fastapi server, a keycloack server and a postgres database. This works well if I run the uvicorn command

python 3 how to generate multiple random element in list for loops

I'm doing a coding exercise and it's to build a password generator. I understand I need to utilize the for loop with the list containing the elements but I'm ha

Firebase SDK for Python: How to initialize App using apiKey?

There is the following code inside a Node.js project: Soon.app = initializeApp({ apiKey: "AIzaSyB4fcG8rtNWAiAtSmxmK3q3JLfMvtNCGP4", projectId: "soonaverse"

Issue with Tensorflow tensor and eager execution

I would like to convert a Tensorflow tensor into a numpy array. My code looks as follows: t = tf.gather_nd(angle, [1,1]) # extract row 1, column 1 element of an

Airflow DAG fails when PythonOperator with error "Negsignal.SIGKILL"

I am running Airflowv1.10.15 on Cloud Composer v1.16.16. My DAG looks like this : from datetime import datetime, timedelta # imports from airflow import DAG fr

Print() statement in Python3 resets when inputting a variable--Visual Studio Community Edition

So, I am learning Python3 and have made use of Visual Studio Community Edition for other languages, such as C# and C. In these, you can do a "WriteLine(my_varia

Walrus operator in Python interpreter

When I use the walrus operator as below in the Python(3.9.6) interpreter, >>> walrus:=True I get a syntax error: File "<stdin>", line 1 wa

How can I add two related nested instance in one request using DRF?

Hi I'm new to Django rest framework I have two models: class Location(models.Model): name = models.CharField(("name"), max_length=50) long = models.Char

Using Type Hints with Brackets [duplicate]

After several hours of chasing this error with an AWS Elastic Beanstalk app (Python 3.8), I learned that I can't use type hints with brackets,

How to compute the TF-IDF for a given word in a document using Whoosh?

I have a dataframe including the following columns: URLFullName Constituency Caucus Province SubjectOfBusiness Intervention time where each row rep

Pyinstaller MacOS Application launching twice

I have an application written in Python and TKInter and complied with PYInstaller. Recently compiled versions appear to launch twice. When I double-click on the

How to desaturate the background of an image in Python

I need to desaturate the background of this kind of images. I thought I can find the largest contour and desaturate everything around. So far I can find the lar

Inserting multiple values into a string

I am trying to run this command but need to insert new two variables for every time I run this command. I think the right approach is to loop through a dictiona

Re-ordering columns in a csv but with Dictionaries

I need to re-order columns in a csv but I'll need to call each column from a dictionary. EXAMPLE: Sample input csv File: $ cat file.csv A,B,C,D,E a1,b1,c1,d1,e1

How to calculate values in Pandas Dataframe itself?

You can see my dataframe below, x values are different value, but other values are same with left values, for example, column 15 and column 16 are same value. I

Django heroku push gives could not build wheels for backports.zoneinfo error

I am trying to push a django project to heroku. heroku create worked fine but when trying to push to heroku main I get the following error. ''' Enumerating obje

django.core.exceptions.FieldError: Unknown field(s) (Actions) specified for Copyrightrece

I want to create 2 models in models.py and 2 forms in forms.py for webpage. but it shows unknown field error #models.py class Copyrightapp(models.Model): S