Category "python-3.x"

Python unit test cannot find module [duplicate]

I have a question about how to correctly import module in python unit test module. this is my directory structure project - | _ Libra

How to show xticks for all 365 distinct tick labels on the X-axis using matplotlib?

I have plotted two line plots. For Y-axis as the number of values are less, the Y-axis is clearly visible. However, for X-axis there are 365 values correspondin

Discord.py: How to fix "event loop is closed"

I am new to programming. I am trying to have my discord bot open up command prompt to confirm it can run, but I am getting this error: File "C:\Users\---\Ap

efficient way of computing a list with mean of values in another list

I need to compute a list with the mean values of another list. To be more precise, the input list have this form: input_list = ['1.538075/42.507325', '1.53796

Weird Python Log Error while trying to reinstall Python on Windows 11

I installed Python on Windows 11 normally after getting the setup from python.org but, by mistake, I deleted the partition Python was installed in (it was E dri

Does Python implement short-circuiting in built-in functions such as min()?

Does Python 3 implement short-circuiting in built-in functions whenever possible, just like it does for boolean statements? A specific example, take the below c

Improving (shortening) my list comprehension with lambda x function?

!!! I know I could use Counter() here, but that's not the point !!! Giving the code below: test =[['a',1],['a',2],['b',3], ['c',5],['a',7],['c',9]] {i:[test[x]

socket.timeout on telegram bot.polling()

When I leave my program running for a few hours and then send a message to the bot it doesn't reply and after a while it generates the following error. Tracebac

when i use docker-compose to install a fastapi project, i got AssertionError:

when I use docker-compose to install a fastapi project, I got AssertionError: jinja2 must be installed to use Jinja2Templates but when I use env to install it,

Airflow without sudo access?

in my virtual env on azure VM, i ran pip3 install apache-airflow when i started airflow db init i received File "/home/shivamanand/myenv/lib/python3.7/site-pack

Dynamically adding a row in data table Kivy/KivyMD

For example I have an empty data table (with only column data) and a button. I want to dynamically add row data when button is pressed. Is it even possible?

Python arrow get list of years between date range

I have this function: def function(start_date_arrow=None,end_date_arrow=None, date_concept=None): list=[getattr(date, date_concept) for date in arrow.Arrow.

Encountering divide by zero after a conditional preventing this

I am writing a simple piece of code for a physics assignment where we are supposed to model a water molecule as a collection of charged particles. I am supposed

How to apply a pandas geocode function to Pyspark column

Table is like this id ADDRESS 0 6101 SUMMITVIEW AVE STE 200 YAKIMA 1 527 CEDAR WAY SUITE 105 OAKMONT 2 1700 N ROSE AVE SUITE 460 OXNARD 3 1275 YORK AVE NEW YOR

discord one script run multiple times

Friends, I am making a discord script using python I have to run this script multiple times with different parameters, I am trying that with os, threading, mult

pytest can't find module for tests

I have a structure like (not exact names) - my_project - app - repo - __init__.py - my_repo.py - services - __init__.py

Trying to read __version__ with setuptools (setup.py) results in FileNotFoundError during build

EDIT: See answer below for explanation of my mistake, and the solution. I was trying to follow the instructions in @dnozay's answer on how to read __version__ i

'Access is denied' to Python 3.8 for PyCharm on Windows 10

Attempting to create a new project in PyCharm Community on Windows 10. Here are the settings for new project in PyCharm: I'm greeted with the error msg: Cannot

problems with """input().split() in loop""" in python

n, m, k, r = tuple([int(i) for i in input().split()]) roads = [] for road in range(m): t = tuple(list(map(int, input().split()))) roads.append(t) pri

FastText 0.9.2 - why is recall 'nan'?

I trained a supervised model in FastText using the Python interface and I'm getting weird results for precision and recall. First, I trained a model: model = fa