Category "python"

python this gpiozero method is not working right of the bat

from gpiozero import MotionSensor While true: MotionSensor(17).when_motion() print("motion detected") returns error: Traceback (most recent call last

Flask restful api with mysql backend crashes when more than 2 apis are called from angular app

We are working on a test project and really do not know Flask and Flask restful much. Our python is not good as well, the problem is, we have developed an API s

Hashing gives different result

I am using Python and MySql to handle user authentication. I have added the users thru python with the exact same method, but when I try to do the "login"/authe

Scene Text Image Super-Resolution for OCR

I am working on an OCR system. A challenge that I'm facing for recognizing the text within ROI is due to the shakiness or motion effect shot or text that is no

Why is my Pytorch code significantly slower than Tensorflow?

I am trying to move my code from Tensorflow to Pytorch. Before doing this, I just simply test myself two frameworks. I expected two frameworks should show simil

Converting windows paths to pathlib.WindowsPath() within a function in python

Edited for clarity I need to be able to copy and paste a windows path directly from file explorer into a function which turns it into a pathlib.WindowsPath() ob

Unexpected errors happen on working script

I'm relatively new to python and only recently tried some small scripts with it that can be used for my needs (just simply interact and automate with some parts

use function to the items in list

originally, beaker is instance and the function below is possible. beaker.replace(z=10) I made a list of beakers bk = [beaker1, beaker2, beaker3] and I want al

ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import)

I'm upgrading an application from Django 1.11.25 (Python 2.6) to Django 3.1.3 (Python 3.8.5) and, when I run manage.py makemigrations, I receive this messasge:

'NoneType' object has no attribute '_inbound_nodes'

I have a code to forecast a time series using an attention mechanism. Here's what I've got so far, but I'm getting an error. def dot_product(x, kernel): if

Performing Excel formula in Python

import numpy K = 1 Rmv = 26 SigS = 111.7 M = 2.050 N = 2 SigD = (-249.4) def Mittelspannung(): result = [] Y = [] SigM = [] for i in rang

TypeError: color must be int or single-element tuple

Here is the error encoutered: TypeError: color must be int or single-element tuple Here is the code I am running: from PIL import Image from PIL import ImageD

How would I run a while loop on a separate thread in Python?

I'm new to coroutines in python but I know in lua you would do this to create one coroutine.wrap(function() while true do end end)() But I dont know how I wo

input() error - NameError: name '...' is not defined

I am getting an error when I try to run this simple script: input_variable = input("Enter your name: ") print("your name is" + input_variable) Let's say I type

How do I check which rows of one small array exists in another larger one?

How do I check which rows of one small array exists in another larger one? Given the following setup: final_batch = np.emtpy((batch_size,2)) batch_size = 4 a =

Why does app.exec_() interactively run out the error 'float' object cannot be interpreted as an integer' after execution?

Sorry, I would like to ask you to help solve some related problems I use the code from this post https://gist.github.com/pklaus/5921022 But there have been prob

Webcrawling: 'NoneType' object has no attribute 'get'

I need to take link to the latest user tiktok video. it worked, but then stopped working import bs4 import requests from fake_useragent import UserAgent from bs

Error inserting values in SQL: Unknown column 'nan' in 'field list'

for row in dfp.itertuples(): cursor.execute(''' INSERT INTO players (PID, NAME) VALUES (%s,%s) ''', (row

Django says that model has no ForeignKey to another model but it really does

Will you help me to figure out why Django raises this error? SolutionsForLanguagesApp.LanguageLevel: (fields.E336) The model is used as an in termediate

How do you compare columns 'a' and 'b' to return 'c' or 'd'?

I am trying to compare two columns and then return a third value from one of the two adjacent columns. I have read that using iterrows is not the correct way to