this post was submitted on 28 Nov 2024
464 points (88.5% liked)

Programmer Humor

32718 readers
353 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 11 points 3 weeks ago (1 children)

Python managed to turn me away before I wrote a single line of code.

Running an already functional project took me nearly two hours and three separate tutorials.

[–] [email protected] 17 points 3 weeks ago (1 children)

What's so difficult?

import project as p

p.run()
[–] [email protected] 13 points 3 weeks ago (4 children)

Hmm, I follow the package's readme and only get invalid command errors.

Gotta install the pip dependencies.

Oh but first you need to create a venv or everything will be global. Why isn't that local by default like with npm? Hell if I know!

Ah but before that I need to install the RIGHT version of Python. The one I already have likely won't do. And that takes AGES.

Oh but even then still just tells me the command is invalid. Ah, great, I live CLIs. Now I've gotta figure out PATH variables again and add python there. Also pip maybe?

Now I can follow the readme's instructions! Assuming I remember to manually open the venv first.

But it only gives me errors about missing pieces. Ugh. But I thought I installed the pip dependencies!

Oh, but turns out there's something about a text file full of another different set of dependencies that I need to explicitly mention via CLI or they won't be installed. And the readme didn't mention that, because that's apparently "obvious". No it's not; I'm just a front-end developer trying to run the darn thing.

Okay. Now it runs. Finally. But there's a weird error. There might be something wrong with my .env file. Maybe if I add a print statement to debug... Why isn't it showing up?

Oooh, I need to fully rebuild if I want it to show up, and the hot reload functionality that you can pass a command line argument for doesn't work... Cool cool cool cool.

[–] [email protected] 4 points 3 weeks ago* (last edited 3 weeks ago)

yeah, all that setup sucks even after being writing python for years.

Nowadays I've been running every project with uv and it's a much better and faster experience, usually in 3 steps: 1. initialize, 2. add dependencies, 3. run project:


# if the project doesn't already have a pyproject.toml with dependencies, initialize it
# uv will also install the right interpreter if not present:
uv init --python 3.13

# anything you would install with pip, use uv add:
uv add dep1 dep2

# run the project / script
uv run main.py

Then in future runs (as long as you have the pyproject.toml), you can just do uv run main.py (shorthand to uv run python main.py), even when there's no venv created. No more activating virtual envs. No more long interpreter installations. No more accidentally messing with system's packages or the PATH variable. With the uv.lock that's also a lot more reliable to reproduce than requirements.txt and similar.

[–] [email protected] 3 points 3 weeks ago

Yeah package system is a nightmare in python I'm so spoiled if Rust that I find it hard to enjoy another language...

[–] [email protected] 2 points 3 weeks ago

This does not reflect my experience with python at all. Except the version thing used to be a thing. Not really any more.

[–] [email protected] 0 points 3 weeks ago

This has way more to do with that specific project being poorly written/not documenting things well than any shortcomings in Python