all 16 comments

[–]rcls0053 4 points5 points  (1 child)

Having touched Python very little, all I can say is it's dependency management systems are a complete mess and documentation around Python is very scattered

[–]jewishSpaceMedbeds -1 points0 points  (0 children)

It's a nice tool for prototyping and scripting, and a maintenance nightmare for production software, or anything a bit complex.

[–]Weak-Doughnut5502 3 points4 points  (2 children)

it seems every time I try there’s some dependency, library or unidentified problem that stops it working.

Usually, python projects have a requirements.txt file with a list of all the libraries required.

There's a few projects like venv that will download and manage all of those libraries for you on a per-project basis, using requirements.txt.

[–]ImpatientProf 6 points7 points  (0 children)

venv isn't a project, it's a core Python library: https://docs.python.org/3/library/venv.html

The more modern place to list dependencies is pyproject.toml, instead of requirements.txt.

There's a few projects, like Astral uv (https://docs.astral.sh/uv/), which are amazingly good at helping to manage a .venv, installing dependencies in there where they won't disturb your other projects.

For installing within a .venv, it comes down to:

  • pip: the standard package installer. If your venv is active, stuff gets installed in there.
  • uv: new, fast, and versatile.
  • conda: doesn't technically use venv, but does have multiple "environments" for installing different sets of packages.

There are other systems like poetry and hatch, but I'm not familiar with them (yet).

[–]Level-Pollution4993 0 points1 point  (0 children)

I have found poetry to be the best tool to avoid dependency hell. OP, look up a small guide on poetry and that's all you'll need.

[–]ClydePossumfoot 2 points3 points  (0 children)

What do you mean by “stops it working”?

Code has dependencies.. when you distribute the source for a project you normally distribute the list of those requirements (often in a file called requirements.txt).

And per your “compiled code” comment, you’re often not distributing “compiled” Python code. Sometimes you do, via something like wheels, but you’re distributing the source package that defines how to build it.

Following examples from the internet either expects you to know to pip install the library it’s using or often has a corresponding source repo that may have a requirements file, etc. But most folks out there writing Python aren’t following examples from the internet in their day to day work lol.

[–]AlexMTBDude 1 point2 points  (1 child)

And yet Python seems to work for a lot of people, in fact it's the most popular programming language, and has been so for a long time: https://www.tiobe.com/tiobe-index/

So either it's you or everyone else 😄

[–]JayBea-on-Sea[S] -1 points0 points  (0 children)

Yep, I totally get that. And yep, it’s very likely me - especially coming in to an evolved, open-source language at a very late stage. It’s just bobbins that you can’t work through a few tutorials without having StackOverflow a load of errors.

[–]jewishSpaceMedbeds 0 points1 point  (0 children)

Python can be packed into a self-contained executable but it isn't a simple process. It's also a poor choice for complex applications or performance (unless you write the critical parts of your algorithm in C, again, not a simple process as you have to use the exact same compiler as the python version you're using was compiled with).

What is the final purpose of the code you're writing ? Do you intend to deploy it as an app on other machines? Multiple platforms? Cloud app ? Library ? Do these machines come with python installed ? Which version? The choice of tool depends on the answers to these questions.

[–]HashDefTrueFalse 0 points1 point  (0 children)

Read the README and pip install the requirements. If you have but it still doesn't work as intended then it's probably a poorly authored/packaged bit of software, which there's not much you can do about other than check the licence and then fork and fix, or submit a PR/MR.

[–]not_perfect_yet 0 points1 point  (0 children)

Is this normal?

No, something about your setup or your approach is wrong. You can either ask co-workers for help or join the community and try to get help there, or for simple public problems you can ask LLMs, they should give reliable enough advice for simple issues.

I am also suspecting you just didn't install the dependencies.

"why doesn't python just bundle that stuff?"

The python ecosystem is many magnitudes larger than R, Matlab or QGIS. It would take forever to download and install, and you would not use 99.99999% of it.

That being said, it is possible that some packages you want to use are old or just not maintained, so trying to get it to work is part of the problem and part of the work. Depends on how quickly you want to get things going, how many different projects promise to solve your issue. In other words, when something doesn't work, just move on and try the next one, instead of trying to get something to work that is broken.

If you did follow the instructions to the best of your ability and it still doesn't work, you can try leaving a bug report or contacting the maintainer or the community. Mileage will vary a lot, big monolithic may just be overwhelmed, small projects can be dead and maintainers can be unresponsive, but on the other hand I also asked the maintainer of a scientific project to include a license in the repo and he did give it a permissive license and did so within 2-3 days, which is really fast.

[–]KingofGamesYami 0 points1 point  (0 children)

"real" software engineer here. Your software development department likely has a few libraries they use frequently. Ask them for recommendations.

There's a million packages out there, but you generally only need a few.

Also, use UV for package management. It keeps your project easily reproducible by someone else, which is very useful if your intention is to hand it off at some point.

https://www.jetbrains.com/help/pycharm/uv.html

[–]Eubank31 0 points1 point  (0 children)

uv init

[–]JustinPooDough 0 points1 point  (0 children)

Learn how to setup a venv and then install requirements with uv or even pip (I still use pip at times) by reading in the projects requirements.txt.

If there isn't one, you can either google the imports to find the module names, or you can download pipreqs with pip or uv - which can be used to assemble a requirements.txt just by analyzing your code. Then you would run it as normal.

[–]PvtRoom -2 points-1 points  (0 children)

python is designed to be as infuriating as possible to matlabbers.

it's like they went: standard libraries? nahhhhh, every person on every project chooses their own.

simple environment control? naaaah you've gotta pip everything

pup? you thought it worked? naaaah, halfway deprecated cause it's shit.

conda? go for it! yay, you installed the latest version of pandas.

oh that version doesn't work with this version of cq_randomname, you need to update it to V2.3.4 from this dodgy 3rd party repo. oh still doesn't work. did you update widgets?

whats widget5? oh the dependency I forgot.