this post was submitted on 29 Jun 2023
406 points (97.9% liked)

Programmer Humor

19623 readers
101 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 60 points 1 year ago* (last edited 1 year ago) (4 children)

Download ML thing.
make new venv.
pip install -r requirements.txt.
pip can't find the right versions.
pip install --update pip.
pip still can't find the right versions.
install conda.
conda breaks for some reason.
fix conda.
install with conda.
pytorch won't compile with CUDA support.
install 2,000,000GB of nvidia crap from conda.
pytorch still won't compile.
install older version of gcc with conda.
pytorch still won't compile.
reinstall the entire operating system with debian 11.
apt can't find shitlib-1.
install shitlib-2.
it's not compatible with shitlib-1.
compile it from source.
automake breaks.
install debian 10.
It actually works.
"Join our discord to get the model".
give up.

[–] [email protected] 18 points 1 year ago

It feels like you stood behind me yesterday, taking notes.

[–] [email protected] 15 points 1 year ago

This comment gives me ptsd

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

thats when you do

/usr/bin/python3.11 -m pip install

mother. fucking. hardcoded paths. 1 step forward, 10 steps backward.

load more comments (1 replies)
[–] [email protected] 31 points 1 year ago (6 children)
[–] pampoon 2 points 1 year ago

[email protected] btw, if anyone wants the link directly.

[[email protected]](https://lemmy.world/c/xkcd) for anyone trying to figure out how to link.

load more comments (5 replies)
[–] [email protected] 26 points 1 year ago

It's like my own little Fediverse

[–] [email protected] 20 points 1 year ago

Feels very validating to see that everyone else's Python is held together by a thread too.

[–] [email protected] 17 points 1 year ago* (last edited 1 year ago) (4 children)

My workflow:

cd project
python -m venv .venv
. ./.venv/bin/activate
pip install -e .

By default pyvenv excludes system packages, so I can have different versions in the venv. To reset the venv, I just have to delete the .venv dir.

[–] [email protected] 3 points 1 year ago (5 children)

I've been using pipenv for a good while but I've started to move over to venv slowly, and I like it so far. It's a bit more of manual work but I feel like it's worth it.

[–] [email protected] 2 points 1 year ago

I love this workflow because it has only two prerequisites: python and pip. It works on windows, linux, any vm or container. Pipenv requires some setup, while this should work everywhere. In powershell you have to use ./.venv/bin/acticate.ps1 but that's the only difference.

[–] [email protected] 2 points 1 year ago

i've moved to just using conda environments. i find it's a lighter load on my old brain.

load more comments (3 replies)
[–] LemmyEnjoyer99 3 points 1 year ago

I use pipenv and the workflow is essentially the same.

cd project
mkdir .venv
python3 -m pipenv shell
pipenv install --dev

It's also nice because VScode (or VSCodium if you're based), automatically detects it to set as your venv.

[–] [email protected] 2 points 1 year ago (1 children)

Seconded, after being burned repeatedly I always do this. But why are you calling activate from the directory above?

[–] [email protected] 6 points 1 year ago

I don't think he does. If you're talking about the third line, there's a space between the dots.

The dot command is equivalent to source (running the script in the context of the current shell).

[–] [email protected] 1 points 1 year ago

Exactly, venv solves this issues for me

[–] [email protected] 17 points 1 year ago (2 children)
load more comments (2 replies)
[–] [email protected] 13 points 1 year ago (3 children)

Thank god for NixOS. (My daily on my laptop, seriously flakes + nix-direnv is godsend for productivity. Reliable development environments and I don’t have to lift a finger!)

[–] [email protected] 5 points 1 year ago (1 children)

Do you have any troubles running it as your daily OS? Do you use it as your hobby or also for your work?

I know Nix and use it as my package manager, but I'm not sure about the experience with NixOS. So I'm still reluctant to make the switch.

load more comments (1 replies)
[–] [email protected] 3 points 1 year ago

I agree. I use a Mac but use nix to manage all this mess.

[–] [email protected] 2 points 1 year ago (1 children)

And the vscode direnv extension just makes it all work together.

[–] [email protected] 4 points 1 year ago

I personally use Neovim (it's not nearly as much work as people make it out to be), so it's all integrated within my terminal.

[–] [email protected] 13 points 1 year ago* (last edited 1 year ago) (3 children)

I've recently discovered pipenv, and it has been a massive QoL improvement. No need to figure out bazillion of commands just to create or start an environment, or deal with what params should you use for it like you do with venv. You just pipenv install -r requirements.txt, and everything is handled for you. And when you need to run it, just pipenv run python script.py and you are good to go.

The best thing however are the .pipfiles, that can be distributed instead of requirements.txt, and I don't get why it's not more common. It's basically requirements, but directly for pipenv, so you don't need to install anything and just pipenv run from the same folder.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

Yessssss

I actually wrote a script to make a folder an instant pipenv environment for me. Add it to your ./.zshrc. Has saved me a ton of time, I just removed some spaghetti lines that would reinstall pip and shit because it's when I was still early days into Py dev, now I work more with Py than I do C# and I'm a senior C# engineer, I just enjoy the masochism of py.

Also added a check for Arch/Ubu.

# Automated python virtual environment.
#######################################
VENV(){
if ! [ -x "$(command -v pipenv)" ]; then
     echo "pipenv not installed... installing it now!"
     sudo pip install pipenv
     OS="$( ( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1 )"
     if [[ "$OS" == *"buntu"* ]]; then
        sudo apt install pipenv -y
     elif  [[ "$OS" == *"rch"* ]];  then
        sudo pacman -S pipenv
     fi
     pip install pipenv --upgrade
     echo "Installation complete!"
fi
if [ -n "$1" ]; then
        echo -e "Args detected, specifically using version $1 of python in this project!"
        version="$1"
else
        version=$(python -V)
        version=$(echo "$version" | sed -e 's/Python //')
        if [ -z "$version" ]; then
                version=$(python3 -V)
                if [ -z "$version" ]; then
                         echo "No python version installed... exiting."
                         return
                fi
        fi
fi
echo -e "\n===========\nCreate a Python $version virtual environment in $PWD/.venv [y/n]?\n==========="
read -r answer
case $answer in
    [yY][eE][sS]|[yY])
export PIPENV_VENV_IN_PROJECT=1
pipenv --python "$version"
pipenv install -r ./requirements.txt
echo -e "\n\n\nVirtual python environment successfully created @ $PWD/.venv!\n"
echo -e "To run commands from this dir use 'pipenv run python ./main.py'"
echo -e "To enter a shell in this venv use 'pipenv shell'."
echo -e "To install from a requirements text file use 'pipenv install -r requirements.txt'"
echo -e "To update pip + all pip modules use 'pipenv update'!\n"
echo -e "Additional information can be found @ https://pipenv-fork.readthedocs.io/en/latest/basics.html"
;;
    [nN][oO]|[nN])
        echo "Fine then weirdo why did you run the command then, jeez.Exiting"
;;
 *)
 echo "Invalid input..."
 ;;
 esac
}
[–] [email protected] 3 points 1 year ago (1 children)

I could redraw this whole chart using only references to pipenv based on my experiences with managing it alongside other tools (especially homebrew). It’s good at many things but is no magic bullet.

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 9 points 1 year ago

Now take all of this and find something that needs an old out of date Python... Like 2.6.

.. cry later

[–] [email protected] 9 points 1 year ago
[–] [email protected] 8 points 1 year ago

Oh, so that is where all of my modules are? That makes total sense, thanks!

[–] [email protected] 8 points 1 year ago

Throw pyenv in there and add some more complexity!

[–] [email protected] 7 points 1 year ago

Hopefully Mojo will sort it all out. Maybe even inspiring a new, positive streak of xkcd strips in the future?

[–] [email protected] 7 points 1 year ago (4 children)

Honestly, at this point I'm running all my python environments in different docker containers. Much easier to maintain.

[–] [email protected] 7 points 1 year ago (7 children)

Wait, you guys don't have a vm for each project and just use ssh to work on them?

load more comments (7 replies)
[–] [email protected] 6 points 1 year ago (1 children)

I've been trying to sell this idea to my team for a year now. I've even done all the legwork in my free time with a personal project and I've offered the patterns to the team. But alas, we still commit to masochism.

[–] entropicshart 2 points 1 year ago* (last edited 1 year ago)

If you haven’t yet, check out PDM; very simple dependency management in virtual environments, with an easy pdm export -o requirements.txt for docker installation.

Makes spinning up a test env for a mock up much easier and then if it grows to something needing docker, it has great dependency management for it.

[–] [email protected] 1 points 1 year ago (1 children)

Agreed! That's the way we do work projects. For personal stuff, I also like using pyenv. But yeah, that's it, keep it nice and simple.

[–] [email protected] 3 points 1 year ago

phew, glad to hear I'm not a total idiot. 👍

[–] [email protected] 5 points 1 year ago

This is now the process to configure your environment for learning Python through Minecraft Java.

[–] [email protected] 4 points 1 year ago

As a mac user I feel this

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

Poetry is nice for this but honestly, Rust's cargo and the JS npm/yarn have spoilt me.

[–] jerrimu 2 points 1 year ago

This Helen’s on my laptop from following AI install scripts. I high key hate Python, it’s my hated language and I wish another language was the default for ML.

[–] wmrch 2 points 1 year ago

So I'm not a software engineer and don't really understand the pros and cons of different Python envs so I just started throwing a fresh self-contained instance of winpython in every project I start working on. Works good enough for me and saves me from all the headaches I got from working with Anaconda envs.

load more comments
view more: next ›