Installed ubuntu22.04 in termux, and there was an error running pip3 after using apt install python3-pip in it, the pip version is 22.02
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/android.py", line 85, in _android_folder
from jnius import autoclass
ModuleNotFoundError: No module named 'jnius'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/usr/lib/python3/dist-packages/pip/_internal/configuration.py", line 26, in <module>
from pip._internal.utils.logging import getLogger
File "/usr/lib/python3/dist-packages/pip/_internal/utils/logging.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir
File "/usr/lib/python3/dist-packages/pip/_internal/utils/misc.py", line 39, in <module>
from pip._internal.locations import get_major_minor_version
File "/usr/lib/python3/dist-packages/pip/_internal/locations/__init__.py", line 14, in <module>
from . import _distutils, _sysconfig
File "/usr/lib/python3/dist-packages/pip/_internal/locations/_distutils.py", line 19, in <module>
from .base import get_major_minor_version
File "/usr/lib/python3/dist-packages/pip/_internal/locations/base.py", line 12, in <module>
USER_CACHE_DIR = appdirs.user_cache_dir("pip")
File "/usr/lib/python3/dist-packages/pip/_internal/utils/appdirs.py", line 17, in user_cache_dir
return _appdirs.user_cache_dir(appname, appauthor=False)
File "/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/__init__.py", line 114, in user_cache_dir
return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_cache_dir
File "/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/android.py", line 43, in user_cache_dir
return self._append_app_name_and_version(_android_folder(), "cache")
File "/usr/lib/python3/dist-packages/pip/_vendor/platformdirs/android.py", line 97, in _android_folder
raise OSError("Cannot find path to android app folder")
OSError: Cannot find path to android app folder
get-pip.py
This is a Python script that uses some bootstrapping logic to install pip.
-
Download the script, from https://bootstrap.pypa.io/get-pip.py.
-
Open a terminal/command prompt,
cd
to the folder containing theget-pip.py
file and run -
python3 get-pip.py
The above method will install pip to /usr/local/bin/pip, and then add a soft link to use it. The problematic version is 22.02, just upgrade to 23
ln -s /usr/local/bin/pip /usr/bin/pip3
Because few people use ubuntu22.04 in termux, this problem is reported wrong and there is no related solution
And because the numpy package in python is required, this pip must be installed, so a more unconventional method is used
Installation - pip documentation v23.0https://pip.pypa.io/en/stable/installation/
wget https://bootstrap.pypa.io/pip/pip.pyz
Download the zip version of pip, and then this can be used normally without error reporting, check the help through the following command
python pip.pyz --help
So you can install Numpy with the following command
python3 pip.pyz install numpy -i https://pypi.mirrors.ustc.edu.cn/simple/
Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/
University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/
Douban http://pypi.douban.com/simple /
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
University of Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/
You can add the -i parameter to the back when using pip to specify the pip source
It works fine after that
Another way is to directly install the compiled package, which seems to be more convenient, the previous one is written for nothing:(
apt-get install python3-numpy python3-scipy python3-matplotlib