I wanted to start contributing to an open source software project yesterday evening, and they recommend virtual box to not mess with your default installation of the program and the databases it uses.

So I thought Debian would be a nice clean distro for developing Python… Gnome feels really unusual to me and I hate it, I guess I can replace it with KDE.

But I couldn’t install a specific Python version? System python is 3.13 but I needed 3.10. I tried adding the deadsnake ppa but Debian didn’t know the add-apt-repository command. So I tried to install software-properties-common which also failed because the package couldn’t be located. Someone on SO said it was removed because security but I mean wtf? So the solution is to add this package cgabbelt manually to sources.list but I couldn’t get it to run because I couldn’t verify the GPG key… Then I went to sleep.

I am pretty sure this community can help with the problem, but honestly, wtf? I am not a Linux power user but a data scientist who works on Linux for a couple of years now, how is it possible installing a specific Python version is such a hassle?

Is Debian just a poor choice for developing? The software I want to contribute to has many dependencies, they recommend Ubuntu but fuck Ubuntu. So I guess I can’t take something too exotic.

  • PM_ME_VINTAGE_30S [he/him]@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    Why not use Miniconda or a similar virtual environment solution? I never ever ever work with the system Python. I always pick my Python version and packages per-project to work best with the other dependencies.

    Gnome feels really unusual to me and I hate it, I guess I can replace it with KDE.

    Yeah I use Debian with KDE on all my systems. Shit’s cash 😎

    Also unrelated, but you ought to bookmark the following article that shows you how to use Jupyter in a multi-environment setup:

    https://bitsofanalytics.org/posts/jupyter-conda-envs/jupyter_conda_envs

    • gigachad@piefed.socialOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      It requires Python > 3.10, but it is not tested very well and I don’t want to provoke incompatibilities. There is no need to run Python 3.13.

      • FishFace@piefed.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 months ago

        If it were me I’d just follow the instructions with python 3.13. You’re very unlikely to run into any problems, and you save yourself this hassle.

  • Rikj000@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    You’ll run into that on many distros,
    not only Debian, since most of the distros use a specific python version for OS packages, its recommended to leave the python for your OS unchanged.

    But VirtualBox is not a good idea either.

    Instead use a venv (virtual environment),
    which is the python way to develop/run under different python versions.

    https://docs.python.org/3/library/venv.html

    • gigachad@piefed.socialOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      I know venv pretty well, but it does not do it for this project. It’s not about isolating the Python libraries, but the system libraries and more importantly the databases the program itself creates. Also I would never install packages into a Python system installation.

      • Successful_Try543@feddit.org
        link
        fedilink
        arrow-up
        0
        ·
        11 months ago

        As @solrize@lemmy.ml already mentioned: Download the python 3.10 source tarball from python.org, unpack, compile and install it. Then run the python3.10 binary with the venv option in the path where you want your venv to be created. By this, the created venv is configured to use the desired (3.10) version of python, not your system’s default version.

    • F04118F@feddit.nl
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      But VirtualBox is not a good idea either.

      Maybe not for Python, but if the database project they’re contributing to relies heavily on modified system libraries, it can be useful to isolate those from your host. Using either a VM or a container can do that.

    • mesa@piefed.social
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      I always do ‘python3 -m venv venv’

      Then activate. Then your usually good.

  • lime!@feddit.nu
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    use something like uv to install whatever python version you want and set up a venv with it. that way you can have project-specific python versions.

    • Olap@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      Seconding uv and adding docker-compose for running dev DBs/services as my recommendation

        • PolarKraken@programming.dev
          link
          fedilink
          English
          arrow-up
          0
          ·
          11 months ago

          If you’ve already got Docker available, testcontainers is awesome!!

          I like little SQLite in-memory DBs for testing sometimes but just accepted the annoying friction of a slightly different SQL dialect (typically use PG). Testcontainers was a “have my cake and eat it too” situation, really like it.

    • gigachad@piefed.socialOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      11 months ago

      Now I found a use case for UV! I am a long time venv user and was always struggling to understand why I should add another complex layer of software into my pipeline. Also when I last tried UV, the recommended way to install it was piping arbitrary code from curl into bash, but maybe that has changed. I have a look, thanks!

      That is a good solution to my problem - but what is the problem with Debian? Am I too old, and is it a bad idea to install a specific Python installation directly into the system?

      • lime!@feddit.nu
        link
        fedilink
        arrow-up
        0
        ·
        11 months ago

        i mean python is 99% backwards compatible so as long as you tell your tooling you’re working with 3.10 it will warn you about using stuff that’s too new. that’s why the shipping version is usually enough. in general it’s not recommended to have multiple versions of python3 installed at the same time, but if you are a habitual venv user it’s usually not a problem. however i have also run into the issue of some versions being “too new” for a project, where the thing just would not work with newer versions.

        basically, if your issue is only that you don’t want to “contaminate” an older codebase, that can be solved by configuring your tooling. but if your issue is that the thing just doesn’t work with the “wrong” version, you’re probably best of using a container. a user installation of the version you want will work but having multiple installations is annoying.

        • gigachad@piefed.socialOP
          link
          fedilink
          English
          arrow-up
          0
          ·
          11 months ago

          It’s not so much about Python itself but the libraries it uses. I experienced very often that the module maintainers for specific libraries require time to port to a newer Python version, and if it only means testing it against it. This is why I have the habit of staying on “2 version older” than the current release. As a data scientist this always made sense for me, I cannot count the times an environment broke because there was a conflict with the Python version. I guess you are right and it probably runs fine. I just wanted to set up my development environment right the first time to save some struggle later. Thanks for your input.

  • data1701d (He/Him)@startrek.website
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    I like to use pythonz in this case; it’s a tool to manage Python installs, and it puts the installs in a directory under your home directory, not affecting anything in the system.

    It does build each version from source, which introduces some quirks; I’ve found compilation for some Python versions works better with clang, and sometimes, you need to enable build options.

    Still, I think this is a good way to do things; just start whichever Python version you want, and then create a venv with it.

  • it_depends_man@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    But I couldn’t install a specific Python version? System python is 3.13 but I needed 3.10.

    The others have covered virtual environments, which is what you need if you really want a 3.10 interpreter.

    But… the thing I’m here to tell you is:

    they recommend virtual box to not mess with your default installation of the program and the databases it uses.

    for many projects this doesn’t actually matter. You can just ignore the warnings, use the most recent version and install whatever you need.

    You’re already sandboxing this stuff in a virtual box, which you should be able to reset or bootstrap again when you need to. You’re not interfering with your actual systems’ python, you’re messing with your virtual box’s system python.

    I find the whole venv stuff to be very annoying, I never need it, because I use libraries that don’t interfere with system operations and I don’t downgrade to interact with projects. And even if you’re not installing “correct” versions, most of the time newer versions fix bugs and expand functionality. It is extremely rare that functions get removed and it will actually break by you not using their exact version. Or like, version conflicts.

    And besides, they would need some kind of CI / testing that would check for compatibility anyway.

    tldr: ignore venvs, try it bare metal, see if something breaks. If not, there you go, if yes, you can still invest the time and effort of learning venvs.

  • prettybunnys@piefed.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    Python is a clusterfuck because so many operating systems rely on it generally, so they may require a version minimum.

    Which version of Debian are you trying to do this with and what version of python?

    I have a repo (why-py3) where I’ve cobtainerized python of various versions with various versions of Debian for “questionable reasons”

    Debian is a great choice for developing, it’s rock solid and stable BUT if you want to be working with bleeding edge packages you may need to use the rolling release Debian which is less stable.

    Or fedora might be more your speed as it has newer packages typically.

    • Sparrow@techhub.social
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      @prettybunnys @gigachad Debian actively prevents you from changing their version to stop you from messing up the system. Consider Pipx or UV to use and install wherever other things you wanted to that way and you won’t have a problem…

      • prettybunnys@piefed.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 months ago

        I’m not talking about removing the system python but rather compiling everything necessary to build a package for differing versions / distros then executing that version and some tools linking that version. It’s dumb, but I needed it when I needed it.

        My use case is/was extremely NICHE but I may be able to provide some help if they really need to go this route.

  • chrash0@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    other commenters have hinted at this, but the main point of most of the good advice is this: don’t use the system Python install (ie the one from apt) for development. uv is my go to, but the idea behind *conda, pyenv, asdf, etc is the same. the underlying OS shouldn’t be an issue; you should be able to ship the code between OSs and build just fine, ideally.

  • solrize@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    Usually you do this with venv. I’m sure there’s a cool kids way to automate everything but it’s not that hard to just download 3.10 (or whatever version you need), compile it, install it into a 3.10 directory, and point your path at it.

    I don’t like Gnome either. I’ve been using MATE which is pretty straightforward, and looks like old-fashioned Windows. Not saying that’s a good thing, but at least for me it had very little learning curve.

    If that project requires Python 3.10 and won’t work with 3.13, that may be a problem in its own right.

  • LeFantome@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    Especially on Debian, I would not be messing with the base / host system so much. This is why a VM is being recommended.

    My solution would be to use Distrobox to run another Linux distro in a container. This could a distro that defaults to a version of Python you need like Arch, Fedora, or Ubuntu.

    This is a good idea even if you use something else to get the Python version you want. Especially so.

    The big advances of this solution are that you get native performance, can see all your normal files, and have an environment that you can customize that does not mess up your host system. You can have other Distroboxes with other tools. You can delete your environment and start over.

    • Successful_Try543@feddit.org
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      Iirc, at least the text installer (I’m not a fan of graphical installers, thus I can’t tell about those) asks if and which DE it should install. You can choose between Gnome, KDE, XFCE, LXQt, and others.

      • frongt@lemmy.zip
        link
        fedilink
        arrow-up
        0
        ·
        11 months ago

        Both the text and graphical installers do. You can also do it afterwards by installing or removing some meta packages or package groups, not sure which one Debian uses.

        • Successful_Try543@feddit.org
          link
          fedilink
          arrow-up
          0
          ·
          11 months ago

          Debian uses tasksel for managing specific tasks like the desktop environment. So

          sudo tasksel install desktop kde  
          sudo tasksel remove desktop gnome
          

          should switch the DE from GNOME to KDE.

  • poweruser@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 months ago

    In addition to others’ answers here, I suggest reading over this document whenever you get frustrated by Debian: Don’t Beak Debian

    Debian has a particular philosophy for its design choices. Using non-standard sources.list entries, for instance, can break your system in the future. You’ll have a much better time in the long run if you come to understand why Debian is the way it is

  • asret@lemmy.zip
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    As others have said [uv] (https://github.com/astral-sh/uv) is likely a good option but since you’ve mentioned being a data scientist you might also check out [pixi] (https://prefix.dev/tools/pixi).

    It’s built on top of conda so will likely have all the packages you might need.

    It’s got quite a nice workflow, keeps things contained in the project directory, and adds a few conveniences over standard conda.