October 22, 2024
Chicago 12, Melborne City, USA
python

Problems with Pygame mixer and ALSA

I’m trying to get pygame to run in a bigger script to play multipule overlapping audios based of key presses, basically to simulate a piano. However, I keep getting the error "pygame.error: ALSA: Couldn’t open audio device: Unknown error 524" whenever I call the pygame.mixer.init() function. I seperated a sample test code to see if

Read More
python

Python in excel does not have the side buttons

I added python in Excel and I am trying to figure it out how it works. In microsoft’s official website it has side menu but my add-in does not show it.enter image description here If you check microsoft, it has 3 buttons : "reset,diagnostics,initialization" https://support.microsoft.com/en-us/office/get-started-with-python-in-excel-a33fbcbe-065b-41d3-82cf-23d05397f53d#:~:text=To%20begin%20using%20Python%20in,a%20cell%20to%20enable%20Python. How can i get them? thanks I tried to remove

Read More
python

Scraping the hulkapps table using Selenium or Beautiful soup

I have this URL that I am trying to scrape: https://papemelroti.com/products/live-free-badge But it seems that I can’t find this table class <table class="hulkapps-table table"><thead><tr><th style="border-top-left-radius: 0px;">Quantity</th><th style="border-top-right-radius: 0px;">Bulk Discount</th><th style="display: none">Add to Cart</th></tr></thead><tbody><tr><td style="border-bottom-left-radius: 0px;">Buy 50 + <span class="hulk-offer-text"></span></td><td style="border-bottom-right-radius: 0px;"><span class="hulkapps-price"><span class="money"><span class="money"> ₱1.00 </span></span> Off</span></td><td style="display: none;"><button type="button" class="AddToCart_0" style="cursor: pointer; font-weight: 600;

Read More
python

This error occurs after packaging the vispy program with pyintsaller

import sys import numpy as np from PyQt5 import QtWidgets from vispy import scene from vispy.app import use_app use_app('PyQt5') N = 500 class MainWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.canvas = scene.SceneCanvas(keys="interactive", show=True) self.canvas.unfreeze() self.canvas.create_native() self.canvas.native.setParent(self) self.main_widget = QtWidgets.QWidget(self) self.setCentralWidget(self.main_widget) layout = QtWidgets.QVBoxLayout(self.main_widget) layout.addWidget(self.canvas.native) button_layout = QtWidgets.QHBoxLayout() layout.addLayout(button_layout) grid = self.canvas.central_widget.add_grid(margin=10) self.xaxis = scene.AxisWidget(orientation='bottom') self.xaxis.height_max = 80

Read More
python

Fixing badly formatted floats with numpy

I am reading a text file only containing floating point numbers using numpy.loadtxt. However, some of the data is corrupted and reads something like X.XXXXXXX+YYY instead of X.XXXXXXXE+YY (Missing E char). I’d like to interpret them as the intended floating point number (or NaN if impossible) and wondered if there was any easy way to

Read More
python

How to create conda env with special proprietary Python from specific location?

I have some proprietary software from SomeCompany (TM) that allows python scripting, but for that one has to use their own special version of python, which is attached to the rest of proprietary files. Let’s call it "proppython.exe" in the path C:\programs\SomeCompany\software\scripting\proppython.exe. I want to create a conda environment that would use that proppython instead

Read More
python

XPath: unconditionally stop scraping at specified element (or EOF)

I’m using python lxml.html package to scrape a HTML file. The HTML I’m trying to scrape that reads in part <h1>Description of DAB Ensemble 1</h1><table>Stuff I don't care about</table> <!-- Tags I don't care about --> <div id="announcement_data_block> <h3>Announcement information</h3> <p>No announcement information is broadcast</p> </div> <!-- More tags I don't care about --> <h1>Description

Read More
python

Loading gsheet data into Python with gspread

This is an example from their docs: import gspread credentials = { "type": "service_account", "project_id": "api-project-XXX", "private_key_id": "2cd … ba4", "private_key": "-----BEGIN PRIVATE KEY-----\nNrDyLw … jINQh/9\n-----END PRIVATE KEY-----\n", "client_email": "473000000000-yoursisdifferent@developer.gserviceaccount.com", "client_id": "473 … hd.apps.googleusercontent.com", ... } gc = gspread.service_account_from_dict(credentials) sh = gc.open("Example spreadsheet") print(sh.sheet1.get('A1')) but what exactly goes in their "Example spreadsheet"? When I copy

Read More
python

Trouble locating a table in an image using OpenCV

Working on extracting text from documents. The text can either be paragraph-like or sectioned and zoned. Tesseract by itself is doing an amazing job at extracting the text, but as you can see from the image the middle section (in red) is a table that doesn’t follow a well defined structure. I don’t care about

Read More
python

How can I start a docker container via an independent docker container?

I have a manager container that I would like to give the ability to start an adjudicator container N times. The adjudicator container does not persist so when it runs, it completes its tasks and then exits. How can I give the manager the ability to start this process over for a set amount of

Read More