Category "python"

Python Enum and Pydantic : accept enum member's composition

I have an enum : from enum import Enum class MyEnum(Enum): val1 = "val1" val2 = "val2" val3 = "val3" I would like to validate a pydantic field bas

'module' object is not callable sgd

Here is my code. from keras.optimizers import gradient_descent_v2 as SGD sgd=SGD(lr=0.01,momentum=0.9,decay=(0.01/25),nesterov=False) I get the following er

How to compare just the date or just date time ignoring seconds in a Python Pandas dataframe column of mixed data types?

In a pandas dataframe, I have a column of mixed data types, such as text, integers and datetimes. I need to find columns where datetimes match: (1) exact values

Connection to the Jupyter Notebook Server could not be established

For the past many months I am trying to code in Jupyter Notebook but whenever I open Jupyter Notebook, then, I see a message where it is written 'A connection t

How do you create a gitignore file in pycharm? (windows)

What i could find relating to git settings on pycharm

How do I align the radiobuttons to left in tkinter?

enter image description here My code shows the radiobuttons unaligned , tap picture to see, and I want to define var(1,2,3,4,5) in some better way. I am very

Apache error log -- how to fix "numpy ImportError" or disable it?

I'm running a Django app on Apache with mod_wsgi -- everything seems to be working but the following error has been clogging up my logs, running every 30 mins o

Split list automatically for multiprocessing

I am learning multiprocessing in Python, and thinking of a problem. I want that for a shared list(nums = mp.Manager().list), is there any way that it automatica

Invalid literal int() with base 10: '[' when doing a filter with request.body

def patch(self, request): Claim.objects.filter(id__in=request.body).update(....) return HttpResponse(status=200) I'm trying to update some of m

Python equivalent to C++ __LINE__

A useful print for debugging in C++ is std::cout << __LINE__ << std::endl; Of course you can simply print a string with the line number, for exa

How to draw repeated slanted lines

I need to draw slanted lines like this programmatically using opencv-python, and it has to be similar in terms of the slant angle and the distance between the l

Pytest: run teardown once for all workers using pytest-xdist

I have a pytest fixture that I need to run only once across all pytest workers. @pytest.fixture(scope="session") @shared # this will call setup once for all pr

How to prevent python program crash when receiving alphabetical characters

My code is working just the way I want - unless input contains alphabetical characters. If so, is crashes. How can I prevent that? My code is as follows: def ma

django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'project.routing'

I have installed django channels and I have added routing.py in project root folder and added the line ASGI_APPLICATION = 'project.routing.application' but whe

'Python' is not recognized as an internal or external command Error when trying do run python commands

I am trying to run a python file and I get the error: 'Python' is not recognized as an internal or external command, operable program or batch file. I know ther

How can I execute custom code using Flow?

I've made a PowerApps app which uploads an image to SharePoint. When Flow detects that this image is uploaded, I want to run a custom script that can interact w

Can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu()

My code in colab worked in January and now it doesn't. It's a Style Transfer program using pytorch (https://github.com/leongatys/PytorchNeuralStyleTransfer). Th

OpenCV Stitcher class not working in Python, always returns ERR_NEED_MORE_IMGS

I'm trying to use the OpenCV Stitcher class for putting two images together. I ran the simple example provided in the answer to this question with the same koal

"Help" Command (Defectio.py, similar to discord.py)

I am using revolt.chat which has a similar API to discord.py called defectio. This is the documentation for the default help command https://github.com/Darkflam

Scrapy spider shows errors of another unrelated spider in the same project

Im trying to create a new spider by running scrapy genspider -t crawl newspider "example.com". This is run in my recently created spider project directory C:\Us