Python version still 2.7 even after removing python2-bin

I’m trying to install python 2.7 to use in compiling TWRP recovery for android 9 and it uses python2 and not python3
so i tried to compile python2 fron AUR but it failed
so i downloaded the python2-bin from AUR
but after that the python version changed to 2.7 while i would just use it to run the compilation, i tried to remove python2-bin but when i run the command: python --version i get:
Python 2.7.12
so how to fix that? and is there a safe way to install both python2 and python3 while keeping the default system version python3 and use the other for just the compilation?

They should provide different binaries so that you can have multiple at a time.

ex; after installing python2 you would just run

python2 things

Without touching python itself.

Well, normally. I dont know about this python2-bin package.

Do you still have python installed?

pacman -Qs python

Maybe we can look at what package owns the executable thing itself

pacman -Qo python

Heres the archwiki too:
https://wiki.archlinux.org/title/Python

1 Like
pacman -Qs python                                                                                   ✔ 
local/boost-libs 1.83.0-4
    Free peer-reviewed portable C++ source libraries (runtime libraries)
local/dbus-python 1.3.2-2
    Python bindings for D-Bus
local/imath 3.1.9-2
    A C++ and python library of 2D and 3D vector, matrix, and math operations for computer graphics
local/libftdi 1.5-5
    A library to talk to FTDI chips, optional python bindings.
local/pyinstaller 6.3.0-1
    Bundles a Python application and all its dependencies into a single package
local/pyside6 6.6.1-1
    Enables the use of Qt6 APIs in Python applications
local/pystring 1.1.4-1
    C++ functions matching the interface and behavior of python string methods with std::string
local/python 3.11.6-1
    The Python programming language
local/python-altgraph 0.17.4-1
    A graph (network) package for constructing graphs, BFS and DFS traversals, topological sort, shortest paths,
    etc. with graphviz output.
local/python-annotated-types 0.6.0-1
    Reusable constraint types to use with typing.Annotated
local/python-attrs 23.1.0-1
    Attributes without boilerplate.
local/python-autocommand 2.2.2-4
    A library to create a command-line program from a function
local/python-babel 2.12.1-2
    A collection of tools for internationalizing Python applications
local/python-build 1.0.3-1
    A simple, correct Python packaging build frontend
local/python-cairo 1.25.1-1
    Python bindings for the cairo graphics library
local/python-certifi 2023.11.17-1
    Python package for providing Mozilla's CA Bundle (using system CA store)
local/python-cffi 1.16.0-1
    Foreign Function Interface for Python calling C code
local/python-chardet 5.2.0-1
    Python3 module for character encoding auto-detection
local/python-charset-normalizer 3.3.2-1
    Encoding and language detection alternative to chardet
local/python-cryptography 41.0.7-1
    A package designed to expose cryptographic recipes and primitives to Python developers
local/python-dateutil 2.8.2-6
    Provides powerful extensions to the standard datetime module
local/python-dbusmock 0.30.2-1
    Mock D-Bus objects for tests
local/python-deprecated 1.2.14-1
    Python @deprecated decorator to deprecate old python classes, functions or methods
local/python-distro 1.9.0-1
    Linux OS platform information API
local/python-docopt 0.6.2-12
    Pythonic argument parser, that will make you smile
local/python-docutils 1:0.20.1-1
    Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX
local/python-execnet 2.0.2-1
    Rapid multi-Python deployment
local/python-fastjsonschema 2.19.1-1
    Fast JSON schema validator for Python
local/python-gobject 3.46.0-1
    Python bindings for GLib/GObject/GIO/GTK
local/python-idna 3.5-1
    Internationalized Domain Names in Applications (IDNA)
local/python-imagesize 1.4.1-4
    Analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG/Netpbm/WebP image headers and returns image size or DPI
local/python-inflect 7.0.0-2
    Correctly generate plurals, singular nouns, ordinals, indefinite articles
local/python-iniconfig 2.0.0-4
    brain-dead simple config-ini parsing
local/python-inquirerpy 0.3.4-6
    Python port of Inquirer.js (A collection of common interactive command-line user interfaces)
local/python-installer 0.7.0-3
    Low-level library for installing a Python package from a wheel distribution
local/python-jaraco.context 4.3.0-3
    Context managers by jaraco
local/python-jaraco.functools 3.9.0-1
    Functools like those found in stdlib
local/python-jaraco.text 3.12.0-1
    Module for text manipulation
local/python-jinja 1:3.1.2-4
    A simple pythonic template language written in Python
local/python-keyutils 0.6-9
    A set of python bindings for keyutils
local/python-lark-parser 1.1.8-1
    A modern parsing library
local/python-lxml 4.9.2-3
    Python3 binding for the libxml2 and libxslt libraries
local/python-mako 1.3.0-1
    A super-fast templating language that borrows the best ideas from the existing templating languages
local/python-manjaro-sdk 1:0.1.1-1
    Manjaro SDK, Python library for easy access to any Manjaro tools or Libs.
local/python-markdown 3.5.1-1
    Python implementation of John Gruber's Markdown
local/python-markupsafe 2.1.3-1
    Implements a XML/HTML/XHTML Markup safe string for Python
local/python-more-itertools 10.1.0-1
    More routines for operating on iterables, beyond itertools
local/python-mutagen 1.47.0-1
    An audio metadata tag reader and writer (python library)
local/python-npyscreen 4.10.5-8
    Python widget library and application framework for programming terminal or console applications
local/python-numpy 1.26.3-1
    Scientific tools for Python
local/python-ordered-set 4.1.0-4
    A MutableSet that remembers its order, so that every entry has an index
local/python-packaging 23.2-1
    Core utilities for Python packages
local/python-periphery 2.3.0-3
    A pure Python 2/3 library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux
local/python-pfzy 0.3.4-3
    Python port of the fzy fuzzy string matching algorithm
local/python-pikepdf 8.11.2-1
    Read and write PDFs with Python, powered by qpdf
local/python-pillow 10.2.0-1
    Python Imaging Library (PIL) fork
local/python-pip 23.3.2-1
    The PyPA recommended tool for installing Python packages
local/python-platformdirs 4.1.0-1
    A library to determine platform-specific system directories
local/python-pluggy 1.3.0-1
    Plugin and hook calling mechanisms for python
local/python-ply 3.11-12
    Implementation of lex and yacc parsing tools
local/python-poetry-core 1.8.1-2
    Poetry PEP 517 Build Backend & Core Utilities
local/python-polib 1.2.0-2
    Pure python library to manipulate, create, modify gettext files (pot, po and mo files).
local/python-prompt_toolkit 3.0.43-1
    Library for building powerful interactive command lines in Python
local/python-psutil 5.9.7-1
    A cross-platform process and system utilities module for Python
local/python-pycparser 2.21-5
    C parser and AST generator written in Python
local/python-pycryptodome 3.19.1-1
    Collection of cryptographic algorithms and protocols, implemented for use from Python 3.
local/python-pycups 2.0.1-6
    Python bindings for libcups
local/python-pycurl 7.45.2-3
    A Python 3.x interface to libcurl
local/python-pydantic 2.5.3-1
    Data parsing and validation using Python type hints
local/python-pydantic-core 1:2.14.6-1
    Core validation logic for pydantic written in rust
local/python-pygments 2.17.2-1
    Python syntax highlighter
local/python-pyproject-hooks 1.0.0-5
    A low-level library for calling build-backends in pyproject.toml-based project
local/python-pyqt5 5.15.10-1 (pyqt5)
    A set of Python bindings for the Qt5 toolkit
local/python-pyqt5-sip 12.13.0-1
    The sip module support for PyQt5
local/python-pyserial 3.5-5
    Multiplatform Serial Port Module for Python
local/python-pysmbc 1.0.25.1-1
    Python 3 bindings for libsmbclient
local/python-pytest 7.4.4-1
    Simple powerful testing with Python
local/python-pytest-xdist 3.5.0-1
    py.test xdist plugin for distributed testing and loop-on-failing modes
local/python-pytz 2023.3.post1-1
    Cross platform time zone library for Python
local/python-reportlab 3.6.12-3
    A proven industry-strength PDF generating solution
local/python-requests 2.31.0-1
    Python HTTP for Humans
local/python-semantic-version 2.10.0-3
    A library implementing the 'SemVer' scheme.
local/python-send2trash 1.8.2-1
    Send file to trash natively
local/python-setproctitle 1.3.3-1
    Allows a python process to change its process title
local/python-setuptools 1:69.0.3-1
    Easily download, build, install, upgrade, and uninstall Python packages
local/python-six 1.16.0-8
    Python 2 and 3 compatibility utilities
local/python-snowballstemmer 2.2.0-5
    Snowball stemming library collection for Python
local/python-sphinx 7.2.6-1
    Python documentation generator
local/python-sphinx-alabaster-theme 0.7.16-1
    Light, configurable Sphinx theme
local/python-sphinxcontrib-applehelp 1.0.7-1
    Sphinx extension which outputs Apple help books
local/python-sphinxcontrib-devhelp 1.0.5-1
    Sphinx extension which outputs Devhelp document
local/python-sphinxcontrib-htmlhelp 2.0.4-1
    Sphinx extension which renders HTML help files
local/python-sphinxcontrib-jsmath 1.0.1-15
    Sphinx extension which renders display math in HTML via JavaScript
local/python-sphinxcontrib-qthelp 1.0.6-1
    Sphinx extension which outputs QtHelp document
local/python-sphinxcontrib-serializinghtml 1.1.9-1
    Sphinx extension which outputs "serialized" HTML files (json and pickle)
local/python-spidev 3.5-1
    Python bindings for Linux SPI access through spidev
local/python-systemd 235-2
    Python bindings for systemd
local/python-tomli 2.0.1-3
    A lil' TOML parser
local/python-tqdm 4.66.1-2
    Fast, Extensible Progress Meter
local/python-trove-classifiers 2024.1.8-1
    Canonical source for classifiers on PyPI (pypi.org)
local/python-typing_extensions 4.9.0-1
    Backported and Experimental Type Hints for Python 3.8+
local/python-urllib3 1.26.18-1
    HTTP library with thread-safe connection pooling and file post support
local/python-validate-pyproject 0.13-1
    Validation library and CLI tool for checking on 'pyproject.toml' files using JSON Schema
local/python-wcwidth 0.2.12-1
    Python library that measures the width of unicode strings rendered to a terminal
local/python-wheel 0.42.0-1
    A built-package format for Python
local/python-wrapt 1.14.1-2
    A Python module for decorators, wrappers and monkey patching
local/python-xxhash 3.2.0-2
    Python binding for xxHash
local/python-yachalk 0.1.5-1
    yachalk python lib for terminal string styling done right
local/python-yaml 6.0.1-2
    Python bindings for YAML, using fast libYAML library
local/shiboken6 6.6.1-1
    Generates bindings for C++ libraries using CPython source code
local/xmldiff 2.6.3-1
    A python tool that figures out the differences between two similar XML files, in the same way the diff utility
    does it
local/zbar 0.23.90-3
    Application and library for reading bar codes from various sources

pacman -Qo python                                                                                   ✔ 
error: No package owns /usr/local/bin/python

So … that tells us things.

Looking at the PKGBUILD

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python2-bin

It appears it just clobbers your /usr/ directory with its own files, including /bin/python.
(which is quite frankly … silly and wrong)
Lying eyes. :sweat_smile:

Anyhoo

sudo pacman -Syu python

That might end up complaining because of existing files, in which case you can remove them first or use overwrite, ex

sudo pacman -Syu python --overwrite '/usr/*'

It doesn’t.

$ pacman -Qlp python2-bin-2.7.18_1-1-x86_64.pkg.tar.zst
python2-bin /usr/
python2-bin /usr/bin/
python2-bin /usr/bin/python2
python2-bin /usr/bin/python2-config
python2-bin /usr/bin/python2.7
python2-bin /usr/bin/python2.7-config
python2-bin /usr/bin/smtpd.py
[...]

It’s saying /local/ for whatever reason. Who knows what OP did with PATH or something…

2 Likes

According to AUR guidelines and Arch package standard - no packages should ever install anything into /usr/local.

echo $PATH

Reason being that /usr/local/ is before /usr in the system $PATH and thus anything placed in /usr/local/bin will shadow /usr/bin/ creating issues with versioning etc.

Same goes for ~/.local/bin/.

These paths are reserved for local fiddling, testing, compiling - you name it - and therefore when the party leaves a mess you have a job of cleaning the house.

1 Like

You could look at pyenv which describes itself as an easy switch between python versions.

1 Like

thank you.
i have renamed use/local/bin to bin1
and now i get:
python --version
Python 3.11.7
this is the output of PATH

echo $PATH    
/home/pc/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

how to reset PATH to its default?

i think i have changed PATH by mistake

i find some tricks here:
https://stackoverflow.com/questions/7237415/python-2-instead-of-python-3-as-the-temporary-default-python
but i had some troubles with them

this is the pyenv output when trying to install python 2.7.12:

pyenv install 2.7.12                                                                              1 ✘ 
Downloading Python-2.7.12.tar.xz...
-> https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
Installing Python-2.7.12...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pc/.pyenv/versions/2.7.12/lib/python2.7/ssl.py", line 97, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (ManjaroLinux 23.1.3 using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20240216111300.17478
Results logged to /tmp/python-build.20240216111300.17478.log

Last 10 log lines:
rm -f /home/pc/.pyenv/versions/2.7.12/share/man/man1/python.1
(cd /home/pc/.pyenv/versions/2.7.12/share/man/man1; ln -s python2.1 python.1)
if test "xno" != "xno"  ; then \
        case no in \
                upgrade) ensurepip="--upgrade" ;; \
                install|*) ensurepip="" ;; \
        esac; \
        LD_LIBRARY_PATH=/tmp/python-build.20240216111300.17478/Python-2.7.12 ./python -E -m ensurepip \
                $ensurepip --root=/ ; \
fi

Your path is as it should be

But you may have messed your system python by the 2.7 experiment.

so the problem is that i have installed python2 in that usr/loca/bin folder ?
the python files are in that folder

possibly - a normal Manjaro system does not support python2.7 and when you install a package providing python2.7 as python you literally sink your system.

1 Like

so what you suggest me to do for running the compilation of twrp with python 2.7?
after syncing the repo this is what i should do:

cd twrp
export ALLOW_MISSING_DEPENDENCIES=true
. build/envsetup.sh
lunch omni_vtr-eng
mka recoveryimage

nothing - port it to python 3 - pyhon2.7 has been deprecated for a long time.

or use a virtual machine where you can setup a virtual environment with python 2.7

1 Like

@ardv, I suggest you remove python2-bin. It’s an old package, from 2022. There is a newer AUR package labeled simply python2, https://aur.archlinux.org/packages/python2, last updated in January of this year. I have installed and used this newer package, calling its command using python2. The plain python command brings up python3. I don’t know if removing the older package and installing this newer package will sort out your path problems.

The StackOverflow page you linked is from 2011. The newest reply to that thread is, yes, dated 2023, but it recommends using conda to install multiple python versions. With Manjaro, it is especially important to use the most recent advice when you do research. On Google or Bing search results page, you can filter the results, selecting the time period under the drop-down menu labeled ‘Tools’. I usually choose ‘Past year’. On DuckDuckGo, the time filter can be selected using the drop-down menu marked ‘Any time’.

2 Likes

It’s python version 2, what do you expect? And it’s deprecated for quite a while now.
The difference between PKGBUILDs is one is compiled binary and the other is not.

filtering the results be date is a very important advice. thank you.

i find this:

by the way. why pacman doesn’t show AUR packages sizes?

when trying to install phyton2 from AUR pacman keeps showing:

ERROR: ld.so: object 'libfakeroot.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Sounds like you need to install base-devel.

sudo pacman -S base-devel
1 Like

That is the stupid way to install things. Have fun removing it.

And how did you figure that?