DEV Community

Cover image for Joys of Installing Python For The Umpteenth Time
Teppo Pölönen
Teppo Pölönen

Posted on

Joys of Installing Python For The Umpteenth Time

Do you know what I love about C?

It's always there.

You can basically log in on any computer, open Vim, write couple lines of code, forget how pointer math works, gcc *.c and badabim badaboom there's your segfault. No problem, easy as pie, Bob's your uncle etc.

Then there's Python.

I've tried to learn Python several times during my decade long journey of hobbyist programmer. Had all the tutorials open, watched the YouTube videos, psyched myself: this time it's going to happen.

Then I try to install it on my computer.

First time I attempted it was... maybe 2013, on Windows. I remember downloading some software package that was supposed to be plug'n'play type of deal - just install this and you have everything you need to start developing with Python.

I think I still have some registry settings and file associations remaining from that attempt that I can't seem to get rid of. I swear I have reinstalled Windows at least twice since then.

This kept repeating every couple of years. We don't need to go too much into detail - I decide to learn Python, try to install it, get confused about virtual environments and eventually some combination of software issues and incompatible hardware wears my motivation down and I give up. Let the snake hibernate for a while.

But today I did it. I finally installed Python.

It was for a project that needed to use Spotify's Web API. Since libspotify is being deprecated and the project needed to get done sooner rather than later, I had to choose between Python and JavaScript.

Needless to say, I suddenly had very strong incentive to learn Python. Spotipy seemed to do everything I wanted in one easy package.

...why'd id it have to be snakes?

It didn't go smoothly.

Although fair's fair: blame is mostly on myself. I tried to do too many things at the same time - Pop_OS update had just gone disastrously wrong, forcing me to reinstall from recovery and also instead of working with Vim like I usually do I decided that this would be a perfect time to start learning VSCode.

Of course, I didn't use Visual Studio Code because I permanently wear a roll of tin foil around my head. I had Code OSS. It worked fine until I tried to do the basic Hello World tutorial.

Pylance didn't work. It didn't recognize any of the standard libraries I tried to import. I guess I could have pushed forward without a language server, but what's the point of using a modern IDE if you don't have all the bells and whistles?

After trawling through pylance/issues & vscode/issues it seemed that

  1. Problem was common and had lots of unspecified causes
  2. It would probably be easier to just bite the bullet and use the Microsoft Approved Visual Studio Code.

More danger noodles.

So I installed it from the Pop!_Shop. I think there was some warning about it being an unofficial flatpak but I paid no mind, that's probably nothing to worry about. Pylance worked so everything was fine. I got Hello World running and hadn't even spent a full day troubleshooting at this point.

Then the problems with shell started. As in VSCode didn't recognize any of the shells that were installed (particularly bash or zsh) and defaulted on xterm, which was basically unusable without massive tinkering.

Maybe the default terminal could be set manually? Current documentation recommended using terminal profiles. It also mentioned that they should be prepopulated with shells already installed on the system.

Naturally, there were no terminal profiles available.

I spent maybe an hour or two trying to create them by editing settings.json with no luck. Searched through StackOverflow, pasted miscellanous snippets and constantly reloaded to see if they had any effect. Nada.

Then I remembered that warning about unofficial flatpaks. I uninstalled this incarnation of VSCode and downloaded the .deb directly from Microsoft's website. And wouldn't you know it, fixed all the issues. Shell profiles were populated, all was well.

Of course, I still had to reload window each time I added a new package or imported a local file to wake up Pylance but that didn't seem to bad at this point. I even went as far as setting up virtualenvwrapper to handle all my venv-related needs. Found about Poetry later but decided not to open a new can of worms 🐍🐍🥫

After a decade of trying, I finally have a working Python development setup.

It only took about 8 hours and years of miserable failures.

sleepy snek

...

...

... Oh, almost forgot. I got the Spotify scraping script working in fifteen minutes with about 20 lines of code. I'd probably have spent couple of days reading through man pages of the C libraries I was planning to use.

There's probably a lesson here but can't think of any.

Top comments (2)

Collapse
 
geraldew profile image
geraldew

Well, if you're going to do links to xkcd then this one seems obligatory for your tale.

Personally I just use Xubuntu with both Python and the libraries I need either pre-installed or easily added via Synaptic. Ditto for a good enough IDE (Geany as it happens). Maybe this was just luck.

Collapse
 
tpolonen profile image
Teppo Pölönen • Edited

I... well... yeah. Hopefully if it ever gets that bad I can just burn my laptop and get a new one from thrift store.

I ended up with VS Code mostly because of peer pressure, seems like everyone uses it almost exclusively in this neck of the woods. Probably should try out other options at some point.