Skip to content

Does not work on Arch Linux subsystem in Termux: OSError: Cannot find path to android app folder #62

@nukemiko

Description

@nukemiko

Description

Unable to use platformdirs in virtual environment created in Termux's Arch Linux subsystem. It will be raise: OSError: Cannot find path to android app folder.

The Arch Linux subsystem is deployed by install script from SDRausty/TermuxArch.

This problem also breaks the functionality of pip because it embeds this module: pypa/pip#10887

A reddit page reported a similar problem: https://www.reddit.com/r/termux/comments/p6l3yh/i_cant_use_python_virtualenv_on_termux_proot/

Python version

3.10.2

platformdirs version

2.4.1

OS

Android 11, Arch Linux subsystem in Termux

How to Reproduce

  1. Deploy a Arch Linux subsystem environment by install script from SDRausty/TermuxArch. Don't add any parameters. The specific link for install script: https://raw.githubusercontent.com/TermuxArch/TermuxArch/master/setupTermuxArch
  2. Install package python and python-platformdirs in the subsystem. (The latest version of python-platformdirs in the Arch Linux arm repositories: 2.4.1-1, python: 3.10.2-1)
  3. Execute python -m platformdirs or from platformdirs import * in python interpreter. You can see the full screen of error messages.

Output

Shell:

# (Skip the part about deploying the subsystem)

u0_a398@localhost:pts/0->/data/data/com.termux/files/home (0)
> startarch

Welcome to Arch Linux in Termux PRoot!
Install a package: pacman -S package
More  information: pacman -[D|F|Q|R|S|T|U]h
Search   packages: pacman -Ss query
Upgrade  packages: pacman -Syu

Chat:   wiki.termux.com/wiki/Community
GitHub: github.com/archlinuxarm
Help:   help man and info man
IRC:    archlinuxarm.org/about/contact

root09:27~$ pacman -Qi python-platformdirs
名字           : python-platformdirs
版本           : 2.4.1-1
描述           : A small Python module for
                 determining appropriate platform-specific dirs, e.g. a "user
                 data dir"
架构           : any
URL            : https://github.com/platformdirs/platformdirs
软件许可       : MIT
组             : 无
提供           : 无
依赖于         : python
可选依赖       : 无
依赖它         : python-virtualenv
被可选依赖     : 无
与它冲突       : 无
取代           : 无
安装后大小     : 121.81 KiB
打包者         : Arch Linux ARM Build System
                 <[email protected]>
编译日期       : 2021年12月28日 星期二 00时30分09秒
安装日期       : 2022年02月07日 星期一 23时25分34秒
安装原因       : 作为其他软件包的依赖关系安装
安装脚本       : 否
验证者         : 数字签名

root09:27~$ python -m platformdirs
-- platformdirs 2.4.1 --
-- app dirs (with optional 'version')
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/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/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.10/site-packages/platformdirs/__main__.py", line 46, in <module>
    main()
  File "/usr/lib/python3.10/site-packages/platformdirs/__main__.py", line 27, in main
    print(f"{prop}: {getattr(dirs, prop)}")
  File "/usr/lib/python3.10/site-packages/platformdirs/android.py", line 21, in user_data_dir
    return self._append_app_name_and_version(_android_folder(), "files")
  File "/usr/lib/python3.10/site-packages/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
root09:27~$ 

Python:

>>> from platformdirs import *
>>> user_data_dir()
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/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 "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/platformdirs/__init__.py", line 50, in user_data_dir
    return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_data_dir
  File "/usr/lib/python3.10/site-packages/platformdirs/android.py", line 21, in user_data_dir
    return self._append_app_name_and_version(_android_folder(), "files")
  File "/usr/lib/python3.10/site-packages/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
>>> site_data_
site_data_dir(   site_data_path(
>>> site_data_dir()
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/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 "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/platformdirs/__init__.py", line 66, in site_data_dir
    return PlatformDirs(appname=appname, appauthor=appauthor, version=version, multipath=multipath).site_data_dir
  File "/usr/lib/python3.10/site-packages/platformdirs/android.py", line 26, in site_data_dir
    return self.user_data_dir
  File "/usr/lib/python3.10/site-packages/platformdirs/android.py", line 21, in user_data_dir
    return self._append_app_name_and_version(_android_folder(), "files")
  File "/usr/lib/python3.10/site-packages/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
>>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions