Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

default python version

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
paulj
Guru
Guru
User avatar
Posts: 546
Joined: Thu Sep 30, 2004 4:55 am
Location: Wales, UK

default python version

  • Quote

Post by paulj » Thu Jan 27, 2022 9:51 am

I have not configured any specific setting for python on my system, and at the moment I have several versions installed:

Code: Select all

[I] dev-lang/python
     Available versions:  
     (2.7)  2.7.18_p13{tbz2}
     (3.6)  3.6.15(3.6/3.6m)^t
     (3.7)  3.7.12_p1(3.7/3.7m)^t
     (3.8)  3.8.12_p1-r1^t
     (3.9)  3.9.9-r1^t{tbz2} ~3.9.10^t
     (3.10) 3.10.0_p1-r1^t{tbz2} ~3.10.1-r2^t ~3.10.1-r3^t ~3.10.2^t
     (3.11) ~3.11.0_alpha3^t ~3.11.0_alpha4^t
       {berkdb bluetooth build examples gdbm hardened libedit lto +ncurses pgo +readline +sqlite +ssl test tk verify-sig wininst +xml}
     Installed versions:  2.7.18_p13(2.7){tbz2}(15:36:20 08/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -berkdb -build -examples -hardened -tk -verify-sig -wininst) 3.9.9-r1(3.9)^t{tbz2}(12:13:47 19/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -build -examples -hardened -lto -pgo -test -tk -verify-sig -wininst) 3.10.0_p1-r1(3.10)^t{tbz2}(12:19:54 19/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -build -examples -hardened -lto -pgo -test -tk -verify-sig -wininst)
     Homepage:            https://www.python.org/
     Description:         An interpreted, interactive, object-oriented programming language
When I run python, the version loaded is 3.9.9 - not version 3.10. From my understanding of the wiki pages, I can install python-exec to select a version for the local user account. However, I don't need a specific version - I am just surprised that the system isn't selecting the latest automatically. Do I need to set something to make this happen?

Thanks!
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Thu Jan 27, 2022 10:18 am

This happens because dev-lang/python-3.10 is marked stable but not the PYTHON_TARGETS python3_10 so the packages with PYTHON_TARGETS compile yet with python3_9.
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
Ionen
Developer
Developer
User avatar
Posts: 3013
Joined: Thu Dec 06, 2018 2:23 pm

  • Quote

Post by Ionen » Thu Jan 27, 2022 10:27 am

Python has a tendency to deprecate things and break old scripts with about every new versions, so Gentoo goes for the safer approach of testing packages before marking them as "python 3.10 compatible" rather than always "use latest".

Then PYTHON_TARGETS and PYTHON_SINGLE_TARGET will decide which python version an installed package will use, e.g. if a package is installed only for python3.8, it will use python3.8 even if your default `python --version` is reporting 3.9.

As noted above, currently profiles are setting those to use python 3.9 given 3.10 support is still work-in-progress (you can use it if you know what you're doing, but generally it's simpler to just use profile versions). Portage does have a tendency to install the latest version of python even if it's not really used (yet) though...

`python --version` is really the version that /you/ want to use (e.g. if you had a random python script in /home/user/bin). By default it'll use the same value as PYTHON_TARGETS given it's what your python libraries are installed for and it makes it a more useful version. This can be configured manually but it's typically handled by dev-lang/python-exec-conf package (replaces the old eselect-python to allow auto-updating based on targets while going through dispatch-conf/etc-update only if you modified it).

...so it is automatic but just doesn't pick latest.

That aside, you could probably get rid of a few version by `emerge --depclean` though, 3.6 through 3.8 shouldn't be needed anymore. python2.7 is still needed to build qtwebengine right now and few other obscure things.
Top
paulj
Guru
Guru
User avatar
Posts: 546
Joined: Thu Sep 30, 2004 4:55 am
Location: Wales, UK

  • Quote

Post by paulj » Thu Jan 27, 2022 12:00 pm

The approach to ensure the correct python version is run for a package is elegant - I was just surprised that running python from the shell doesn't select the latest version. Running "python3.10" works as expected.
my make.conf doesn't define PYTHON_TARGETS and PYTHON_SINGLE_TARGET any more - I removed this last year.

Anyway, for what I am doing, 3.9 is fine, I was just intrigued! Thanks to you both for the explanations!
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Thu Jan 27, 2022 12:14 pm

paulj wrote:The approach to ensure the correct python version is run for a package is elegant - I was just surprised that running python from the shell doesn't select the latest version. Running "python3.10" works as expected.
This happens because if you don't have python-exec installed the system use dev-lang/python-exec-conf to select the python command line version and this package follow the PYTHON_TARGETS.
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
Post Reply

5 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic