Category "python"

How to connect to postgres on another server where postgres is on docker?

I can connect to postgres in that way. On my local machine i run: ssh name@ip -p 22 input --> password and then sudo docker-compose exec postgres bash afte

Python patch returning magicmock instead of return value

I have this code import cv2 from src.utilities.binary import message2binary from src.utilities.stegUtils import verify_payload def encode(input_path: any, paylo

How to plot Acutal and predictions in python (While 0 and 1)

How to plot the Acutal vs Prediction graph in python. It's was 0 and 1 values so plot is not meaningful.

Django can't save userprofile instance during saving forms

I am getting this error Cannot assign "<QuerySet [<UserProfile: UserProfile object (131)>]>": "BlogComment.userprofile" must be a "UserProfile" ins

Converting the values of the dictionary in to a file in Python

I have a dictionary say : my_map_dict which looks something like below: {2: [['1', '2', '4', '4', '0', '2', '0', '0.67'], ['5', '6', '3', '8', '0', '2', '1', '0

How to go through all Pydantic validators even if one fails, and then raise multiple ValueErrors in a FastAPI response?

Is it possible to call all validators to get back a full list of errors? @validator('password', always=True) def validate_password1(cls, value): password =

Cannot install Python 3.7 on osx-arm64

I am trying to create a new environment with Python 3.7 using Conda like: conda create -n qnn python=3.7 I got following errors: Collecting package metadata (

Trying multiprocessing but the program dies before it even starts

I have this code: from multiprocessing import Process, cpu_count def readplayerinfo(): y=0 Gameon = True while Gameon: y+=1 print('

How to move desktop icons with python?

I am making a python program that moves the desktop icons using LVM_SETITEMPOSITION from winapi but I have a problem with commctrl.LVM_SETITEMPOSITION and it gi

Object is not subscriptable python error django

I have this function where i am using models 'Start' and 'End' that contain fields latitude and longitude.. and I am trying to match them with a field called el

How can I add users in a private room with a command when they are mentioned?

I am creating a command and in this command when I run it, it has to create a room and add the people mentioned. Instead, it adds the user who used the command.

google-cloud-resource-manage list projects 403 The caller does not have permission

I created a GCP service account and assigned the needed permissions for listing the projects inside the organization. When I'm using the gcloud cli, everything

Error in executing YOLO .txt annotations to .csv converter

I'm having trouble executing this file. Given that I'm working on a multi-class classification, each .txt file has several lines addressing each object in every

How can i find selected area in photo using OpenCV?

I need to detect a selected area in a photo: Original photo: I used this code: import cv2 as cv import numpy as np img = cv.imread(cv.samples.findFile('./Pict

In openpyxl, is there a way to see what conditional formatting rule(s) are applied to a cell?

I'm using openpyxl 2.5.6 and py 3.7.0. My goal is to read an Excel workbook and print both the contents and the formatting of each cell into a CSV. For instance

Python PIL save method rotates image

I have a little issue with saving image with PIL. In my Django project I have the following save method: from PIL import Image class Photo: image = models.

Vowpal Wabbit negative weights significance

I'm doing a feature study and I was wondering what the negative feature weights in the audit output signify. I'm currently using the contextual bandits function

How to train only the last convolutional layer?

Could you help me with the code such that along with the dense layers also the last convolutional layer of Efficientnet is trained as well ? features_url ="http

How to change colour when I click a button in guizero Python 3?

So I have written this piece of code in python3 guizero to change colour to red when I click the button I created. But whatever I do it's not working! I am not

Use C preprocessor macros (just the constants) as Python variables

I am writing a Python code which needs to interoperate with C code which I also wrote. In C I have a section like #define FOO 23 // whatever #define BAR 54.3