Results 1 to 10 of 10

Thread: Python latest version

  1. #1

    Default Python latest version

    Hello,

    I've been reading about Python programming on Linux and apparently the recommended way to manage multiple versions of Python is to use a 'Python version management tool' like f.e. pyenv to prevent issues with the system version of Python. Please correct me if this is wrong.

    What I'm wondering is, what if I use something like pyenv and change the version locally or globally, won't this affect system packages when they try to execute python code? Will the packages use this new version, or will they still be linked to the system version?

    Thx

  2. #2

    Default Re: Python latest version

    No I did not resolve it yet, but I think it won't cause any problems if I use the local version.
    Globally is another question...

  3. #3
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,868
    Blog Entries
    2

    Default Re: Python latest version

    Here are some answers and suggestions...

    Unlike some distros, openSUSE comes with its own python, and the python that comes from your OSS repository is generally a collection of commonly needed Python components to run apps... not necessary to develop.

    If you want to develop or at least build apps that might require components not in the OSS, like any other development language there is a special repo you can add that will usually also offer a newer and sometimes older version of python components... In other words, this python repo can often address any missing python or compatibility problems. Because python both from the OSS and the python repo are accessible using zypper and YaST, you don't need to know too much more than what you would need to know for general package management.

    To install the openSUSE python repo for your version of openSUSE, first open a web browser to the following and then click on one of the repos to view/browse the path to your distro

    https://download.opensuse.org/reposi...uages:/python/

    From the above, you can for instance add the repo for LEAP 15.2 to your system with the following zypper command
    Code:
    zypper ar -f https://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Leap_15.2/ LEAP_15.2_python
    The above should be good enough for most students and is fairly simple to manage and code.

    But,
    If you're doing some serious python programming, you might need to build to multiple python versions or to a version older or newer than what openSUSE provides.
    For these, you'll want to download and use Pythons from PyPi, the official Python repositories.
    And, you'll be using pip instead of zypper as your main package management command.
    And, you'll likely want to use a python management tool like pyenv (or the legacy virtualenv) so that you'll have flexibility to install entire pythons side by side oand switch between them on your system.
    Although I have yet to see a global setting cause a system error, I'd probably be a bit wary of the possibility... Which reminds me...
    You should seriously consider doing all your coding in a virtual machine unless your project absolutely requires real, physical access to hardware. It's very well known that typical code development can compromise system security, cause unexpected conflicts and accelerates all the junk accumulation in your system. Do all your coding in virtual machines (I dedicate at least one virtual machine to every project I work on) and you shouldn't ever have a problem and your base machine is kept clean.

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  4. #4
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,174

    Default Re: Python latest version

    Quote Originally Posted by chrisdb View Post
    Hello,

    I've been reading about Python programming on Linux and apparently the recommended way to manage multiple versions of Python is to use a 'Python version management tool' like f.e. pyenv to prevent issues with the system version of Python. Please correct me if this is wrong.

    What I'm wondering is, what if I use something like pyenv and change the version locally or globally, won't this affect system packages when they try to execute python code? Will the packages use this new version, or will they still be linked to the system version?

    Thx
    pyenv is a good solution for this - it creates a sandboxed space for Python applications to run, so it doesn't change the version of python either locally or globally - rather, it's used to manage the python modules that your code uses. You still would use either python2 or python3 (and update-alternatives can be used to set one of those as the default).

    As others have noted, python is used by openSUSE for various things as well. It's my experience - as a long-time coder in python (going on 10 years now) - that you do not need to install the official python packages from python.org on openSUSE. There's no need to play around with virtual machines or Docker or anything like that.

    I would recommend a good editor with syntax checking. I've used ActiveState's Komodo Edit (a no-cost option). They have an IDE as well that recently also became free of charge (neither is open source to the best of my knowledge, but I find them both to be quite good - and they understand the differences between python2 and python3). The IDE does some code completion as well, but I find that that sometimes gets in the way of my coding (it triggers on keywords, and if those keywords are, for example, in comments - it creates a codeblock anyways that isn't desired).

    Jim
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,868
    Blog Entries
    2

    Default Re: Python latest version

    Quote Originally Posted by hendersj View Post
    pyenv is a good solution for this - it creates a sandboxed space for Python applications to run, so it doesn't change the version of python either locally or globally - rather, it's used to manage the python modules that your code uses. You still would use either python2 or python3 (and update-alternatives can be used to set one of those as the default).

    As others have noted, python is used by openSUSE for various things as well. It's my experience - as a long-time coder in python (going on 10 years now) - that you do not need to install the official python packages from python.org on openSUSE. There's no need to play around with virtual machines or Docker or anything like that.

    I would recommend a good editor with syntax checking. I've used ActiveState's Komodo Edit (a no-cost option). They have an IDE as well that recently also became free of charge (neither is open source to the best of my knowledge, but I find them both to be quite good - and they understand the differences between python2 and python3). The IDE does some code completion as well, but I find that that sometimes gets in the way of my coding (it triggers on keywords, and if those keywords are, for example, in comments - it creates a codeblock anyways that isn't desired).

    Jim
    Would be curious what you are using as your guide and/or tutorial for using pyenv as you describe.

    The official pyenv documentation describes very different usage...

    https://github.com/pyenv/pyenv

    Not saying it's not possible to do what you describe, but would like to read about it.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  6. #6

    Default Re: Python latest version

    I just tried something else... Apparently it's possible to install another Python version next to the system one.

    So now I have 3 versions:
    - Python 2.7 -> python
    - Python 3.6 -> python3
    - Python 3.9 -> python39

    The main python3 version still points to 3.6, so apparently the binaries can work next to each other

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,868
    Blog Entries
    2

    Default Re: Python latest version

    Quote Originally Posted by chrisdb View Post
    I just tried something else... Apparently it's possible to install another Python version next to the system one.

    So now I have 3 versions:
    - Python 2.7 -> python
    - Python 3.6 -> python3
    - Python 3.9 -> python39

    The main python3 version still points to 3.6, so apparently the binaries can work next to each other
    Yes,
    This is an important feature of python management like pyenv (same for others),
    You can install multiple python side by side and test your code with each...
    This is important if you build apps for distribution and want to ensure your app works on a number of systems which run different python.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  8. #8
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,174

    Default Re: Python latest version

    Quote Originally Posted by tsu2 View Post
    Would be curious what you are using as your guide and/or tutorial for using pyenv as you describe.

    The official pyenv documentation describes very different usage...

    https://github.com/pyenv/pyenv

    Not saying it's not possible to do what you describe, but would like to read about it.

    TSU
    Actually, I was thinking of something else - https://docs.python.org/3/library/venv.html.

    Jim
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  9. #9
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,868
    Blog Entries
    2

    Default Re: Python latest version

    Quote Originally Posted by hendersj View Post
    Actually, I was thinking of something else - https://docs.python.org/3/library/venv.html.

    Jim
    Understandable.
    There are so many python virtual enironment (envelope) tools available!
    Speaking of which, it's interesting to catch up on the competition between these tools periodically...
    The following is only a couple months old as of this writing, and seems to do a fairly good job of describing which tool one should choose... and venv is recommended. I remember when I last looked at venv, it had a reputation of being limited compared to others, but it looks like it also has some positives to balance its negatives. Fans of pyenv won't find much in this link, IMO because it stands apart from the others by likely supporting all the features you'd want. It also doesn't hurt that from time to time I use rbenv to similarly manage ruby projects, and the structure and syntax of pyenv and rbenv are similar.

    https://stackoverflow.com/questions/...rtualenvwrappe

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  10. #10

    Default Re: Python latest version

    Quote Originally Posted by tsu2 View Post
    Yes,
    This is an important feature of python management like pyenv (same for others),
    You can install multiple python side by side and test your code with each...
    This is important if you build apps for distribution and want to ensure your app works on a number of systems which run different python.

    TSU
    No, I didn't use pyenv here, just the experimental package of python39 from:
    https://download.opensuse.org/reposi...n:Factory.repo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •