r/pythonhelp • • Oct 16 '20

Selenium returning element not found error for for find_element_by_xpath

3 Upvotes

Hey all,

I'm new to Python, and I'm trying to use Selenium to automate downloading. My intention is to click the download button on this website (or the equivalent for different datasets). I've tried various methods of selecting the element, but none work. Currently I'm using the xpath, copied from Firefox's inspector. The path syntax appears valid (finding by id and using the * to search all xpaths), so I don't know what's causing the issue. Since other methods don't work either, I suspect I'm making some basic error using the driver.

Code:

browser.get("https://data.census.gov/cedsci/table?q=ACSDT1Y2018&tid=ACSDT1Y2018.B00001&tp=true&hidePreview=true")
browser.find_element_by_xpath('//*[@id="toolbar-download"]').click()

Any suggestions?


r/pythonhelp • • Oct 14 '20

Among Us Help

3 Upvotes

it is a among us imposter detector but only the final response is actually counting.

https://repl.it/@zandernew/GargantuanCompetitiveInitializationfile#AMong


r/pythonhelp • • Oct 13 '20

TypeError: '<' not supported between instances of 'function' and 'int' (PLEASE HELP)

3 Upvotes

I'm new to Python and keep getting this error. Can some please help me? Thanks in advance.

def main ():

intro()

get_income()

get_number()

compute_assistance(get_income, get_number)

def intro():

print("\nWelcome to our financial assistance program. ")

print("In order for us to assist you, we'll need some information. ")

print("Your eligibility and amount of assistance will depend on a couple of factors. ")

def get_income():

income = float(input("\nPlease enter annual household income: $"))

while income < 0:

print("Error! Income must exceed zero ")

print("Re-enter Income ", end='')

income = float(input(": "))

return 'income'

def get_number():

number = int(input("Please enter number of children: "))

while number < 0:

print("Error! Cannot have negative children ")

print("Re-enter number of children ", end='')

number = int(input(": "))

return 'number'

def compute_assistance(income, number):

if income in range (30000, 40000) and number >= 3:

total_assistance = float(1000 * number)

print("You qualify for $", format(total_assistance,',.2f'), "in financial assistance! ")

print("You are eligible to receive $1000.00 per child based on your income. ")

elif income in range (20000, 30000) and number >=2:

total_assistance = float(1500 * number)

print("You qualify for $", format(total_assistance,',.2f'), "in financial assistance! ")

print("You are eligible to receive $1500.00 per child based on your income. ")

elif income < 20000:

total_assistance = float(1500 * number)

print("You qualify for $", format(total_assistance,',.2f'), "in financial assistance! ")

print("You are eligible to receive $2000.00 per child based on your income. ")

else:

print("You do not qualify for financial assistance. ")

return 'total_assistance'

main()


r/pythonhelp • • Oct 10 '20

Python Poetry

3 Upvotes

For the Python poetry lovers with good heart, willing to give me a hint with this poem ;) Let me know if you got BTC wallet or Patreon and I will be happy to compensate you :)

“We have developed speed, but we have shut ourselves in. Machinery that gives abundance has left us in want. Our knowledge has made us cynical. Our cleverness, hard and unkind. We think too much and feel too little. More than machinery we need humanity. More than cleverness we need kindness and gentleness.”

  1. Order all the sentences of the text according to their length (number of words per sentence) and it should be presented in the following order: the longest sentence first, the second longest thereafter and so on (e.g., ‘The longest sentence in this text contains “X” words”; The second longest sentence in this text contains “Y” words, ...., and the shortest sentence in this text contains “Z” words’).

  2. Extract five longest words in the entire text, create a List with those items and order them alphabetically. Print out these results on the screen (e.g., ‘Five longest words in this text ordered alphabetically are: “word1”, “word2”, “word3”, “word4”, “word5”’).


r/pythonhelp • • Oct 03 '20

It gives me this output no matter what I change, I’m looking for it to just display the equation with x^-3 in place of x. Why? How to fix???

Thumbnail
gallery
3 Upvotes

r/pythonhelp • • Sep 04 '20

Does anyone know how to remove auto-complete from spyder (Python 3.8)

Post image
3 Upvotes

r/pythonhelp • • Aug 08 '20

Pygame help

3 Upvotes

Hi there,

Hope everyone is doing well, for my A level Comp Sci project i have decided to make a "Logic Gate Simulator", where it will displays pictures of logic gates and I cant seem to add a AND gate on this screen, when i run the code, a picture of the AND gate appears and then it goes to the menu. I dont want that to happen i want it to display the image in the logic gates section.

I dont know if i posted this on the right subreddit or not but if anyone can please help me it will be greatly appreciated.

For the menu i found some code and tweaked it to fit my project.

I want the AND logic Gate to appear here, but i cant seem to find a solution and how to make it appear

I want make an AND gate appear when i click on logic gates.

This is my menu


r/pythonhelp • • Aug 02 '20

Title.fuction? HELP PLEASE

Post image
3 Upvotes

r/pythonhelp • • Jul 15 '20

I'm new but why is it not saying 'a is bigger than b by a lot'

3 Upvotes

r/pythonhelp • • May 30 '20

How to use python/kivy to record and play audio on iOS and Android?

3 Upvotes

Trying to create cross platform kivy app that records and plays audio as part of the functionality. I used pyaudio to handle everything and recording and playing audio works fine on my laptop running Linux. Tried uploading what I have so far to my Android phone using buildozer and the app immediately quit, looking at the logs showed that it couldn't install pyaudio.Did some research and apparently as of now there is no way to run pyaudio on Android. Tried using the module sounddevice instead, got the same problem. I found another module available on PyPI, called sound, documentation is here: http://omz-software.com/pythonista/docs/ios/sound.html#module-sound.

Looking at the documentation says it works on iOS, but looking at the package on PyPI shows that it's still early in development, and trying it out in the python shell shows that most of the functions are missing still. For Android, I know I could use pyjnius to record and play audio with Android's Java functions and use plyer too, but I don't know if there is an equivalent to pyjnius for calling Swift instead of Java for iOS. Plyer also can't use audio i/o on iOS. I did find, however pyobjus for calling Objective-C, and something here, which I don't understand. I really don't want to have to maintain multiple code bases, that's why I used kivy in in the first place. Worst case scenario, I have multiple code bases and I learn Swift for iOS and Dart for Android. Does anyone happen to know the best way to record and play audio with python on Android and iOS?

Edit:

Did a little more research on plyer/pyobjus capabilities on this repository. This person added an iOS audio implementation that's very similar to the android counterpart that was included before in plyer, which is good. Specific to my project, I need to use recording and playing audio for mic streaming on mobile. For example, someone speaks into their phone and their voice plays somewhere else. I also found this?


r/pythonhelp • • May 05 '20

FIX for pygame not working on MacOS

3 Upvotes

I spent a lot of time looking around the internet for a solution to pygame's display not initializing on mac os.

Here is the solution if anyone else ends up needing it, just uninstall pygame if already installed and run this command:

pip3 install pygame==2.0.0.dev6


r/pythonhelp • • Apr 27 '20

Help me out, why does this only print the last line of text in my csv file (there are 4 lines)

Post image
3 Upvotes

r/pythonhelp • • Dec 26 '19

Beginner help with print command with multiple variables

3 Upvotes

What is the proper way for print(message0, message1, message2, message3,) to have each variable on the next line?

I have tried doing '\n' before and after each variable and only get a syntax error. I have also tried doing ,'\n\n\n\n', as I saw on another forum, and that did not work out.


r/pythonhelp • • Dec 13 '19

Help me please! I’m trying to modify files, but when i run it, it wipes the file clean??

Post image
3 Upvotes

r/pythonhelp • • Feb 25 '19

Can't figure out how to solve this for my online class

3 Upvotes

Create a list consisting of the negative values in the list numbers. Associate the new list with the variable negatives.


r/pythonhelp • • Jan 19 '19

Struggling to "fire" some python code from GitHub

3 Upvotes

I'm struggling to run some python code from GitHub. I've been writing my own very simple code but I'm nowhere near competent enough to see what I'm doing wrong with someone else's code.

I use the Spyder IDE through Anaconda and don't run code from the command prompt in Windows.

I'm trying to convert Charities Commission BCP files (contained within a Zip file) to CSV. There is Python code on Github to do exactly that here: https://github.com/ncvo/charity-commission-extract

The guide to the code says to run the command "python /path/to/script/import.py /path/to/download/zip/RegPlusExtract_February_2015.zip" at the command prompt (which I've tried and failed to do - assume as I only have the Anaconda / Spyder install).

I've opened import.py in the Spyder IDE and have import.py, bcp.py and the current, December extract all in the same folder. I assume that I can amend a line in import.py to point to the December extract but I can't see which one and now I'm stuck.

Any help very gratefully received.


r/pythonhelp • • Jan 01 '19

character encoding for argv

3 Upvotes

Hello, I do not program in Python often. Working on a CLI utility for generating DKIM key pairs, one of the optional arguments is for the mailbox domain the key pair is to be used for. I am allowing unicode domain names and converting them to IDNA but when I do that I assume UTF-8 for the input encoding. Is there a (Python 2.7 compatible) way to detect the actual character encoding that is being used for the arguments?

https://gitlab.com/Pipfrosch/gnutls-for-librelamp/blob/master/PYTHON/dkim-keygen.py is my program, the two lines I use to handle non ASCII domain names are at line 311 currently (where the script handles the -d switch)


r/pythonhelp • • Dec 14 '17

Merging 2 lists of same length

3 Upvotes

list1 = ["a","b"] list2 = ["c","d"]

<some magic here>

out:

["ac","bd"]


r/pythonhelp • • Oct 17 '26

Python beginner!!

2 Upvotes

Beginner here: how would you structure my nested if statements in a two-step login program?

Hi all, I'm about 3 weeks into learning Python (Python for Everybody on Coursera) and just finished my first small project: a login program that asks for a passcode, then a second passcode, then lets the user pick a report.

My main question is about structure. I have nested if statements, and the second user repeats the same checks in a separate elif branch. Here's a trimmed version of the layout:

admin_login = input("Enter Passcode")

if admin_login == boss_code:
second_pass = input("enter second passcode")
if second_pass == boss_secondcode:
report = input("enter report number")
if report == "1":
print("report 1")
elif report == "2":
print("report 2")
elif admin_login == ass_code:
# same second-passcode and report checks repeated here

I'd love feedback on:

  1. Is the code organized in a clear, readable way?

  2. Is there a cleaner way to stack or avoid repeating these nested ifs, using only what a beginner would know (no classes yet)?

Full code and README are here: https://github.com/tylerkilgore148-can/python_learning_projects

I know the passcodes are stored in plain text, which is just for practice. I plan to look at getpass and hashing next. Beginner-friendly tips are very welcome, and thanks for reading!


r/pythonhelp • • Jul 31 '26

PyQt Architecture: A dedicated module/Worker for every button action (5–15 KB per file)? Best practice or overengineering?

2 Upvotes

Hi everyone,

I'm currently building a desktop application using PyQt6, where button clicks trigger various background tasks (such as executing external processes, creating/cloning environments, file I/O operations, etc.).

To keep the UI responsive and the codebase easily maintainable, I decided to extract every main button action into its own dedicated module/file, using the standard QThread + QObject (Worker) pattern.

To give you an idea of the scale: individual module sizes range between 5 and 15 KB depending on what the button actually does (from simpler tasks to complex operations involving user input processing, thread setup, process streaming, and progress signal handling).

Note on Code Sharing: Any logic shared across multiple buttons is not duplicated; instead, it is abstracted into dedicated shared service modules located in button/logic/services.

My current architecture for a single button action looks like this:

  • GUI Layer (View): Captures the button click and delegates control to a dedicated action handler.

  • Action Handler (Controller / Mediator): A dedicated module for that specific action. It gathers user inputs (via dialogs), instantiates QThread and QObject (Worker), connects signals (for progress bars and logging), and starts the thread.

  • Worker (QObject): A non-GUI worker running in a worker thread, responsible strictly for execution flow (subprocesses, file manipulation) and emitting signals to send status updates back to the UI.

  • Shared Logic Helpers (button/logic/services): Shared domain modules and services called by the workers to execute common underlying logic.

My questions for the community:

  1. Is creating a separate 5–15 KB file/module for each button action (combining the Handler + Worker) considered standard practice in medium-to-large Qt applications? Or do you prefer grouping related actions into larger domain managers ?

  2. For modules of this size, do you keep the Handler and Worker together in a single file, or do you split them further into separate _worker.py and _handler.py files?

  3. Are there any hidden downsides or pitfalls to this level of decoupling when the application scales up to dozens of individual buttons and actions?

I'd love to hear how you structure background tasks and threading in production PyQt/PySide applications! Thanks!


r/pythonhelp • • Jul 07 '26

name errors in this python script for firefox bookmarks?

2 Upvotes

I am sorry if this breaks rules, but under some time pressure.

NameError: name 'print_html' is not defined

I am very new at this and trying to export firefox bookmarks from a friends phone that desperately needs a factory reset. Do not really want to use sync if it can be avoided. Yes I am old school.

https://gist.github.com/v3l0c1r4pt0r/15ef7181b7c4546963da68bc3b31c169


r/pythonhelp • • Jul 03 '26

I built YO — an interpreted language that reads like English, with a VS Code extension, playground, and PyPI package

2 Upvotes

Hey r/pythonhelp ,

I'm a final-year CS student, and over the past few months I've been building YO, a small interpreted programming language written from scratch in Python.

The original goal was to learn how interpreters work by implementing my own lexer, parser, and interpreter. As the project evolved, I became interested in one specific question:

Can compiler/interpreter error messages actively teach beginners instead of simply reporting what's wrong?

I'm not claiming YO is a replacement for Python, JavaScript, or any established language. It has no ecosystem, and it's implemented as a tree-walk interpreter, so performance isn't the goal.

Instead, I focused on making diagnostics more educational.

Example

Python:

"hello" - 5


TypeError: unsupported operand type(s) for -: 'str' and 'int'

YO:

say "hello" - 5


❌ [E003] Type Mismatch

Can't use '-' between String and Int.

"hello" is text.
5 is a number.

Fix:
Use text.str(5) if you intended to concatenate.

Example:
"hello" + text.str(5)

Another example:

❌ [E001] 'scroe' was used but never made.

Did you mean 'score'?

Fix:
Create it first using:

make score = ...

Technical implementation

  • Handwritten lexer

  • Recursive descent parser

  • Tree-walk interpreter

  • Lexical scoping and closures

  • Multi-error reporting (reports multiple diagnostics instead of stopping at the first error)

  • Error codes with yo explain E001 for detailed explanations

  • Standard libraries for math, text, and lists

  • 27 automated tests with GitHub Actions CI

Small informal study

I also ran a small informal comparison with 10 first-time programmers.

Both groups received the same program containing three bugs. One group used Python, while the other used YO.

The YO group fixed the bugs faster on average.

The sample is small and not intended as rigorous research, but I included the methodology, raw results, and limitations in the repository for anyone interested.

Try it

→ GitHub

→ pip install yo-lang PyPI

→ VS Code extension search "YO Language" on the Marketplace

→ Browser playground (no install): Playground

I'm especially interested in feedback from people who have built interpreters or compilers.

Do you think "errors that teach" is an area worth exploring in language design, or is it mainly valuable only for complete beginners?

I'd also be happy to answer questions about the lexer, parser, interpreter architecture, or implementation decisions.


r/pythonhelp • • May 27 '26

Python Web Scraping & Automation Engineer Looking for Remote Work

2 Upvotes

Hi everyone,

I’m a Python Automation & Web Scraping Engineer with experience building large-scale scraping pipelines and automation systems for US-based clients.

Skills include:

• Selenium / Playwright

• APIs & data extraction

• Python automation

• ETL workflows

• Linux servers & cron jobs

• CSV/JSON/XLSX exports

Looking for remote freelance, contract, or long-term work related to web scraping, automation, or data engineering.

Feel free to DM me if you’re hiring or need help with a project.


r/pythonhelp • • May 14 '26

Hi im trying to get started and i have hit a snag

2 Upvotes

i need some help. so i don't know what did wrong i got python installed, i got pygame_ce installed but it seems something is wrong. the link is to a screenshot of me trying to use Sublime text i hope that helps https://cdn.discordapp.com/attachments/1115340096242204792/1504384590880444576/image.png?ex=6a06cad4&is=6a057954&hm=31d60171b7142ca179c312bba4652cb7137c385d37243e1cbc8a49591d30a7e7&