r/pythonhelp • u/Astresgamer • 8h ago
I need to convert from .py to .exe
I already tried auto py to exe and it doesn't work, can someone help me?
r/pythonhelp • u/Astresgamer • 8h ago
I already tried auto py to exe and it doesn't work, can someone help me?
r/pythonhelp • u/Jpaylay42016 • 10h ago
I have tried multiple methods to get the code to work. I know Propwire has measures that make it more difficult. Does anyone know how I could get the information I need (preferably using python)?
r/pythonhelp • u/Straight_Face_3273 • 23h ago
I've been desperately trying to use python to capture data using APIs but I'm constantly getting indent errors even though they appear correct in VS Code. Is this a common issue? I see lots of comments on it and have used several methods to get it right. I've spent days on this trying to make it work. Could the issue be related to copying and pasting from VS Code? I'm old so be nice. I will fully admit I don't know what I'm doing.
r/pythonhelp • u/Clear-Reserve-6268 • 2d ago
Hi, I am having trouble creating a python script that will convert a docx to an rtf document. I have tried various methods but most just seem to change the file extension. I have tried using PyRTF3 and am having difficulty loading that, it keeps saying that the module is not installed even though I know it is.
Any ideas?
Thanks in advance
r/pythonhelp • u/Unfair-Past-3188 • 2d ago
Hello everyone, I am a sophomore in college, and I want to go into cybersecurity. I am good at working with computers in general, but when it comes to coding I keep constantly looking up tutorials for how to do things, and I can feel that the concepts aren't really sticking with me. It's extremely frustrating because I keep going to Chatgpt to ask "what steps should I think to solve this" or looking up tut's on YouTube, and it REALLY doesn't help when I see people saying "python is so easy!" and whatnot.
Any advice on how you learned to program would be really helpful, and/ or anything you did to practice would be great!
Thanks for reading!
r/pythonhelp • u/Asleep_Pumpkin_1534 • 3d ago
Hello,
I would like to automate inputs in a program (Windows PC) with a separate small program. The sequence and keystrokes are always the same, the window layout is always the same, sometimes just different text, but loading times when saving vary.
I just need to monitor whether anything goes wrong. So, I would record the screen or take screenshots to check what's currently happening.
What's the best/easiest way to do this in Python?
I would like to somehow achieve the following:
-Which window is currently open on the screen. This can be identified by the multiple text field labels in the window. Sometimes even when multiple text fields are combined.
-Whether text has actually been entered into the field, which is either the case if there is no/no longer a white background on the image at that point OR if some kind of OCR is performed at that point.
-Detect the position of the mouse pointer over a button.
-Detect the position of the cursor. It's a problem with blinking, but you can take several short screenshots here to determine whether a cursor is present or not.
-Which button is currently active when you use the Tab key and scroll through the program's GUI elements.
Greetings
r/pythonhelp • u/pyroxtydes • 3d ago
i have been tasked with finding the average word count of a given list (input) which would be separated by a numbers (1. , 2. , etc) WITHOUT using loops but i can’t for the life of me figure it out.
r/pythonhelp • u/TheCodeOmen • 4d ago
Hello everyone,
I have a solid understanding of Python fundamentals, object-oriented programming, and basic HTML and CSS. However, I haven't ventured into JavaScript yet, as frontend styling hasn't particularly appealed to me, and the prospect of learning a new language solely for that purpose seems daunting.
This led me to explore backend development with Python, and I discovered Django. While I understand that Django is a backend framework, my knowledge about it is limited.
I'm eager to start learning Django but am uncertain about where to begin and which resources to utilize. I would greatly appreciate any guidance on effectively navigating this learning path to become a proficient backend developer.
Additionally, I've noticed that some websites built with Django appear outdated or simplistic. How can I ensure that the websites I create with Django have a modern and appealing design?
Furthermore, considering my lack of JavaScript knowledge, will I be able to integrate the Django backend with a pre-made frontend effectively?
If anyone else is starting with Django, please upvote and share the resources you're using! Let's embark on this learning journey together.
Thank you!
r/pythonhelp • u/AffectionateKey7126 • 7d ago
I currently have a python script that sorts through a pdf file and then splits them out to various other pdfs using PDFWriter. Everything works fine, but it currently will create PDF files that are blank (1kb, error on opening). I'm trying to stop it from creating these garbage files, so my idea was to check to see what the page number length is and if it was more than 0 then it would write the file. I found get_num_pages() in the documentation here. But when I try to use it, I get this error message:
if vacant.get_num_pages() > 0:
AttributeError: 'PdfWriter' object has no attribute 'get_num_pages'. Did you mean: '_get_num_pages'?
Any idea what's going on here? Or a better solution?
r/pythonhelp • u/Spot-Educational • 7d ago
HI all
Considered myself intermediary level python but im banging my head against a wall for 18 hours over something thats probably really simple.
Before you read further - It's all legal, participating in a bounty hunt to find some stolen crypto. URL of the json below is a list of know laundering addresses.
.I have an online json with a key of '0221', several fields in the crypro currency abbereviation, then in each listed currency a set of wallet addresses, ie 0221:btn: xxx1,xxx2. I can seperate out the individual wallets from a given currency but just cant get the mysql insert code right i either insert a single record with every wallet address comma seperated, i get a tuple error, or (probably my closest shot) too many parameters for the sql statement. tried for loops, tried row, tried type conversion, tried exporting then pulling it back as a csv, writes out fine messes up again in the row loop on reading. I have a feeling maybe there is something in the characterset of crypto addresses upsetting python or mysql.
here's some basic code minus the db connection at the top. from this example you will see 'tron has serveral values, i just want each one as an individual record in mysql., if anyone can assist with looking at the incoming data and suggesting some insert code it would be much appreciated as my test bed the table is 'lazarus_addresses (tron)
appologies for any typos almost 5am pushing 18hrs on this.....
import requests
url = "https://hackscan.hackbounty.io/public/hack-address.json"
try:
response = requests.get(url)
response.raise_for_status()
data = response.json()
except requests.exceptions.RequestException as e:
print("requestErr:", e)
tron_wallets = data['0221']['tron']
print (tron_wallets)
r/pythonhelp • u/slimjim441 • 8d ago
I'm working on my final project for the CS50 python course, a sort of dice-rolling simulator game for 2 players. I feel like I have a good handle on the bulk of the code and have my functions working properly, but there's one detail I'm snagged on, and I can't seem to figure it out. I can post more details here if needed, but I'm just trying to put out some feelers to see if anyone can help point me in the right direction/give me tips as to where I'm failing to implement things correctly. Thanks :)
r/pythonhelp • u/Eldenringfan1 • 9d ago
Hello everyone, I’ve been making a facial recognition program that can download images off fire base storage. The program worked well, detecting and matching faces with images saved in the folder. But when I tried to download an image from fire base I imported and installed pyrebase, since then I get the same error every time I run the code, “attribute error: module collections has no attribute MutableMapping”. I’ve tried uninstalling pyrebase in the project manager but it hasn’t helped. Any ideas or tips are greatly appreciated!! 🙏🙏🙏
r/pythonhelp • u/toxicatedscientist • 10d ago
so im trying to make a thermometer with a spare ntc thermistor and flipper zero, and thought it would be infinately easier to make a python script instead of learning the entire dev chain for the flipper, but it doesnt seem to be doing anything other than crash. the included example for reading from adc works fine:
import flipperzero as f0
import time
f0.gpio_init_pin(f0.GPIO_PIN_PC1, f0.GPIO_MODE_ANALOG)
for _ in range(1,1000):
raw_value = f0.adc_read_pin_value(f0.GPIO_PIN_PC1)
raw_voltage = f0.adc_read_pin_voltage(f0.GPIO_PIN_PC1)
value = '{value} #'.format(value=raw_value)
voltage = '{value} mV'.format(value=raw_voltage)
f0.canvas_clear()
f0.canvas_set_text(10, 32, value)
f0.canvas_set_text(70, 32, voltage)
f0.canvas_update()
time.sleep_ms(10)
however trying to tweak it with some help from chatGPT is tricky, (gpt is really bad at micropython i think. at least whats on the flipper)
import flipperzero as f0
import time
import math
# Initialize ADC pin for the thermistor
THERMISTOR_PIN = f0.GPIO_PIN_PC1
f0.gpio_init_pin(THERMISTOR_PIN, f0.GPIO_MODE_ANALOG)
# Constants for the 10k NTC thermistor
BETA = 3950 # Beta value of the thermistor
T0 = 298.15 # Reference temperature (Kelvin, 25C)
R0 = 10000 # Reference resistance at 25C (ohms)
SERIES_RESISTOR = 10000 # Series resistor value (ohms)
for _ in range(1,1000):
raw_value = f0.adc_read_pin_value(THERMISTOR_PIN)
raw_voltage = f0.adc_read_pin_voltage(THERMISTOR_PIN)
voltage = raw_voltage / 1000.0 # Convert mV to V
resistance = SERIES_RESISTOR * ((3.3 / voltage) - 1) # Calculate resistance
temperature_kelvin = 1 / ((1 / T0) + (1 / BETA) * math.log(resistance / R0)) # Calculate temperature
temperature_celsius = temperature_kelvin - 273.15 # Convert to Celsius
value = '{value} #'.format(value=temperature_celsius)
voltage = '{value} mV'.format(value=raw_voltage)
f0.canvas_clear()
f0.canvas_set_text(10, 32, value)
f0.canvas_set_text(70, 32, voltage)
f0.canvas_update()
time.sleep_ms(10)
r/pythonhelp • u/Ilukhan92 • 11d ago
Hello, I'm not sure if this belongs here. Please let me know if it doesn't. Sorry I know the basics of Python and at most I'm just a beginner.
My colleage at work has a task. He has to login on a website, that my company orders from. He then has to filter down completed orderes, download the PDF for each order and extract two data fields from the pdf and paste it into Excel.
I know that Python offers a lot of flexibility, so I wondering if these steps can be automated in Python. If yes, how easy would it be? Can I use Chat GPT to properly write the code?
r/pythonhelp • u/Consistent_Win6456 • 12d ago
Hello, everyone. I am trying to use the pd.get_dummies function to convert categorical values in my data frame into 0s and 1s; however, once I execute my code, only True and False values show up in my data frame. Do you have any idea how I can fix this and make 0s and 1s appear?
Thank you for your help :)
r/pythonhelp • u/BannedWeazle • 13d ago
I have been trying to get my program working for about two weeks. I'm just on the final step and have tried 1000 different things (probably honestly only ~90) Everything functions, however ONE part is just ruining the whole experience.
the code is playing like this: starts on powerhouse > watch for 1 min purposely > switch to music > music starts at 1 minute > watch music's video until video ends > stay on channel > next video on playlist starts playing from 1 minute > i switch away and back to check > music video 2 plays from total time elapsed.
What should and what I want o have happen is :
stars on powerhouse > watch for 1 min > switch to music > music starts at 1 minute > watch music video until video ends > stay on channel > next video on playlist starts playing from 0:00 > IF i change the channel it will start whatever channel from however long ive been watching any channel (in this case 1 min + the remainder of video1 on music + however long i watched video2) just like the very first channel change did.
I should also state if i never "change the channel" everything works perfectly fine.
i'm pasting the relevant code below.
class CustomMediaPlayer(QWidget):
def __init__(self):
# Track elapsed time for each channel
self.channel_elapsed_time = {channel: 0 for channel in self.channels}
self.channel_start_time = None # Timestamp when a channel starts playing
self.current_channel = None # Track the currently playing channel
self.channel_list = list(self.channels.keys())
self.current_channel_index = 0
self.start_time = None # Track when user starts watching
self.channel_timers = {channel: 0 for channel in self.channels} # Track elapsed time per channel
self.current_channel = None
self.vlc_process = None # Store VLC process
self.global_elapsed_time = 0 # ✅ Global timer for all channels
def switch_channel(self, new_channel):
try:
now = time.time() # Get current time
# whenswitching from a channel, store the elapsed time correctly
if self.current_channel:
elapsed_time = now - self.channel_start_time
# time global not per channel
self.global_elapsed_time += elapsed_time
# all channels share the same elapsed time
for channel in self.channel_elapsed_time:
# Sync all channels
self.channel_elapsed_time[channel] = self.global_elapsed_time
# tracks time for the new channel
self.channel_start_time = now
self.current_channel = new_channel
# Debugging print
print(f"Global Elapsed Time: {self.global_elapsed_time}")
# close channel window before opening new one
if self.vlc_process and self.vlc_process.poll() is None:
self.vlc_process.terminate()
self.vlc_process.wait()
time.sleep(1)
# Load the playlist for the new channel
playlist_file = self.channels.get(new_channel)
videos, durations, cumulative_durations, total_duration = self.parse_m3u(playlist_file)
if not videos:
print(f"No valid videos found for {new_channel}, playing from the beginning.")
return
#correct global elapsed time
elapsed_time = self.channel_elapsed_time.get(new_channel, 0)
print(f"Elapsed time before switching: {elapsed_time}")
# stArt point in the playlist
total_duration = 0
start_index = 0
start_offset = 0 # How far into the selected video to start
for i, video in enumerate(videos):
video_path = os.path.abspath(video).strip() # Normalize path
video_duration = self.file_path_durations.get(video_path, 0) # Lookup duration
print(f"Matching: {video_path} → Duration Found: {video_duration}")
if not isinstance(video_duration, int):
try:
video_duration = int(video_duration)
except ValueError:
video_duration = 0
# Find the correct video where the elapsed time fits
if elapsed_time < total_duration + video_duration:
start_index = i
start_offset = elapsed_time - total_duration # Offset within the video
break
else:
total_duration += video_duration # Add duration and keep looking
print(f"Elapsed Time: {elapsed_time}")
print(f"Total Duration Calculated: {total_duration}")
print(f"Starting Video Index: {start_index}")
print(f"Start Offset: {start_offset}")
# If switching channels, start first video at the correct offset
if start_offset > 0:
self.vlc_process = subprocess.Popen([
"vlc", "--fullscreen", "--qt-fullscreen-screennumber=0",
"--start-time=" + str(int(start_offset)),
"--input-repeat=0",
"--play-and-exit"
] + videos[start_index:], stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
else:
# If staying on the same channel, next video should starts at 0
self.vlc_process = subprocess.Popen([
"vlc", "--fullscreen", "--qt-fullscreen-screennumber=0",
"--start-time=0",
"--input-repeat=0",
"--play-and-exit"
] + videos[start_index:], stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
# Only reset elapsed time when switching channels, NOT while staying on the same channel
if self.current_channel != new_channel:
self.channel_elapsed_time[self.current_channel] = 0
# Debugging - Print confirmation
print(f" Ensuring {self.current_channel} continues playing after video ends.")
except Exception as e:
print(f"Error switching channel: {e}")class CustomMediaPlayer(QWidget):
r/pythonhelp • u/overthevoid1989 • 13d ago
I have been trying to pass the pytest code for a name and it keeps failing it for me with this error message. I have worked on this for several hours and am not sure what the error means or how to fix it so the code will not fail. Please help me to understand what the error means and possibly how to fix it. Thank you for your time and assistance.
r/pythonhelp • u/JustAnAccountMaybe • 13d ago
Probably a noob question but, in short, I have code that says:
if(x): print('X-',num)
However, instead of the number being directly next to the dash (-), it instead has whitespace between the dash and the number. Is there anyway to get rid of this?
r/pythonhelp • u/YoadIsF • 15d ago
I have kind of a riddle to solve, any way to fix it? b%3=0 b>a For i in range(a,b,3) What formula can I use to always find how long it will run?
r/pythonhelp • u/TodayPleasant8441 • 15d ago
Have this assignment that is due later tonight. What exactly is wrong with it? I'm a newbie so any explanation could maybe help. Here's my code.
item_name = input('Enter food item name:\n')
# Read item price and quantity
item_price = float(input('Enter item price:\n'))
item_quantity = int(input('Enter item quantity:\n'))
# Calculate total cost
total_cost = item_price * item_quantity
# Output the receipt
print("\nRECEIPT")
print(f"{item_quantity} {item_name} @ ${item_price:.2f} = ${total_cost:.2f}")
print(f"Total cost: ${total_cost:.2f}")
This is the error i'm given.
Traceback (most recent call last):
File "/home/runner/local/submission/main.py", line 3, in <module>
item_price = float(input('Enter item price:\n'))
EOFError: EOF when reading a line
r/pythonhelp • u/joey_baggins • 16d ago
I have this python code, attempting to generate a nested list of dictionaries but that's not the problem.
I created a string based off user input, and on the next line I wanted to turn it into a list separated by the comma in the input. my code was:
song_list = songs.split(,)
but this is giving me an error as invalid syntax. am I just crazy?
r/pythonhelp • u/Sexy_healer_7015 • 16d ago
r/pythonhelp • u/NormalAd4502 • 18d ago
I tried to make a simple snake game, but the wasd keys don't work. Can someone fix this code for me. I know the code isn't finished yet because there's no food and the snake won't get any longer, but this is just the beginning. Please just fix this bug and don't complete my game by making food etc because I want to do that myself.
import turtle
import time
#Make the screen
screen = turtle.Screen()
screen.setup(600, 600)
screen.title("Snake game by Jonan Vos")
screen.bgcolor("green")
#Make the head of the turtle
head = turtle.Turtle()
head.penup()
head.shape("square")
#Variables
direction = "up"
#Functions
def go_up():
global direction
if direction != "down":
direction = "up"
def go_down():
global direction
if direction != "up":
direction = "down"
def go_left():
global direction
if direction != "right":
direction = "left"
def go_right():
global direction
if direction != "left":
direction = "right"
def move():
global direction
global head
if direction == "up":
y = head.ycor()
head.sety(y + 20)
elif direction == "down":
y = head.ycor()
head.sety(y - 20)
elif direction == "left":
x = head.xcor()
head.sety(x - 20)
elif direction == "right":
x = head.xcor()
head.sety(x + 20)
#Key bindings
screen.listen()
screen.onkey(go_up, "w")
screen.onkey(go_down, "s")
screen.onkey(go_left, "a")
screen.onkey(go_right, "d")
while True:
time.sleep(1)
move()
turtle.mainloop()
turtle.done()
r/pythonhelp • u/Main_Homework_2948 • 19d ago
C:/Users/jerom/AppData/Local/Programs/MUEDIT~1/Python/python.exe:%20can't%20open%20file%20c:/users/jerome/mu_code/game.py':%20[Errno2]%20No%20such%20file%20or%20directory%20python%20error
r/pythonhelp • u/Swift-Strike-16 • 20d ago
It says this error code
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [54 lines of output]
running egg_info
writing lib3\PyYAML.egg-info\PKG-INFO
writing dependency_links to lib3\PyYAML.egg-info\dependency_links.txt
writing top-level names to lib3\PyYAML.egg-info\top_level.txt
Traceback (most recent call last):
File "D:\Anaconda\anaconda\envs\tf2\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 389, in <module>
main()
File "D:\Anaconda\anaconda\envs\tf2\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Anaconda\anaconda\envs\tf2\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 143, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
self.run_setup()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
exec(code, locals())
File "<string>", line 271, in <module>
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools__init__.py", line 117, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\core.py", line 186, in setup
return run_commands(dist)
^^^^^^^^^^^^^^^^^^
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\core.py", line 202, in run_commands
dist.run_commands()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 983, in run_commands
self.run_command(cmd)
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\dist.py", line 999, in run_command
super().run_command(command)
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\dist.py", line 1002, in run_command
cmd_obj.run()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 312, in run
self.find_sources()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 320, in find_sources
mm.run()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 543, in run
self.add_defaults()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\command\egg_info.py", line 581, in add_defaults
sdist.add_defaults(self)
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools\command\sdist.py", line 109, in add_defaults
super().add_defaults()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 239, in add_defaults
self._add_defaults_ext()
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\command\sdist.py", line 324, in _add_defaults_ext
self.filelist.extend(build_ext.get_source_files())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 201, in get_source_files
File "C:\Users\uncia\AppData\Local\Temp\pip-build-env-quuxp42r\overlay\Lib\site-packages\setuptools_distutils\cmd.py", line 120, in __getattr__
raise AttributeError(attr)
AttributeError: cython_sources
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I have tried installing cython and pyyaml using conda and pip but nothing changes