Stack Overflow » Python
2,394 FOLLOWERS
Learn here to write a python program, ask version-specific Python questions, or chat about anything involving python programming.
Stack Overflow is empowering the world to develop technology through collective knowledge.
Stack Overflow » Python
1h ago
The Champernowne constant is 0.123456789101112131415...
What is a more efficient method of calculating the first occurance of a string of numbers (eg, the string "12" first occurs at index 1, not "12" even though it's there as well) than the one scripted in python below? Trivially, you can concatenate a looping variable and do an index search of the resultant string. But that is only practical for numbers below 10**7. The scipt below can handle a 200 digit number in a few minutes.
It's an interesting problem than is applicable to data compression.
import random
while True:
x=ax=random.ran ..read more
Stack Overflow » Python
1h ago
I have this function in my main code that prints the loggings in the terminal and it works fine:
def log_parameters(self):
logging.basicConfig(level=logging.INFO)
logging.info("Loaded configuration:")
for section, params in self.config.items():
logging.info(f"\t{section}:")
Now in my Gui code which I used PyQt, I'm trying to show the loggings on the display but it shows nothing:
get_config_button = self.create_styled_button("Get Config")
get_config_button.clicked.connect(self.get_config)
monitor_hbox.addWidget(get_config_button)
self.log_buffer = StringIO()
self.log_hand ..read more
Stack Overflow » Python
1h ago
I'm trying to put someting like tk.CTkEntry(master=self, placeholder_text="Amount") in a list (or anything alse). I think I tried every "list like" option.
Any Ideas how to do that ?
It schould be someting like:
button[1] = tk.CTkEntry(master=self, placeholder_text="Amount ..read more
Stack Overflow » Python
1h ago
I needed to have Python torchaudio library installed for my application which is packaged into a Docker image.
I am able to do this easily on my EC2 instance easily:
pip3 install torchaudio
python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchaudio
>>> torchaudio.__version__
'2.2.1+cu121'
But not through my Dockerfile, here's what I have in my Dockerfile:
RUN pip3 install --target=/opt/prod/lib/python3.8/site-packages torchaudio
but when I entered into the docker c ..read more
Stack Overflow » Python
1h ago
To write a bot using Selenium, I need the Google driver, but it seems like there's no driver available for the newer versions of Chrome. What should I do? I tried to install older versions of Chrome, but I still encountered an error ..read more
Stack Overflow » Python
1h ago
I am running a pyspark script on EMR version 6.13.0 and have installed neccessary packages using bootstrap as below: #!/bin/bash sudo yum update -y sudo python3 -m pip install pandas PyDictionary numpy nltk boto3 sudo python3 -m nltk.downloader -d /usr/share/nltk_data all sudo python3 -m venv -d /usr/bin/virtualenv all sudo python3 -m pip install pyarrow venv-pack
I keep running into an error related to Virtualenv, java.lang.RuntimeException: Failed to run command: /usr/bin/virtualenv -p python3 --no-pip --system-site-packages virtualenv_application_ ..read more
Stack Overflow » Python
1h ago
I have a simple setup, Arduino reading a load cell sensor and sending data to a laptop via python script. I am using the bleak module for connecting to the HM10 Bluetooth device. I am having trouble decoding the sent data. Any help? (And yes I am a total noob and am using ChatGPT)
Arduino code for sending the data:
if (sendValues) {
float reading = scale.get_units();
String dataToSend = String(reading); // Pretvaranje float u String
BT.write(dataToSend.c_str()); // Slanje Stringa kao niza bajtova
delay(50);
Python code for receiving and decoding:
async def connect_to_hm10 ..read more
Stack Overflow » Python
1h ago
Problem when importing the ImageDataGenerator from keras.
I tried using:
from tensorflow import ImageDataGenerator from tensorflow.keras.preprocessing import ImageDataGenerator
Creating alias for keras and/or tensorflow, no success.
Receiving the following Error Message:
File "/Users/////training/zz_train.py", line 8, in from tensorflow.keras.preprocessing import ImageDataGenerator ImportError: cannot import name 'ImageDataGenerator' from 'tensorflow.keras.preprocessing' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/keras/_tf_keras/keras/preprocessing/init.py ..read more
Stack Overflow » Python
1h ago
I was trying some event commands but i was just more confused from when I started.
I was trying to see some tutorials on internet but,again they confused me ..read more
Stack Overflow » Python
1h ago
I have python script inside container which needs two arguments to run. I tried to run the script using Makefile.
For this I made make command:
.PHONY: deploy
deploy:
@docker exec -it ecosystem python3 deployment/deploy.py $(filter-out $@,$(MAKECMDGOALS))
When I run make deploy server project, the script works, but when it finishes I get the following error: make: *** No rule to make target 'server'. Stop ..read more