Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法使用pip安装Python库,在设置 ANDROID_DATA 环境变量后可修复 #39

Open
DBinK opened this issue Apr 18, 2024 · 6 comments

Comments

@DBinK
Copy link

DBinK commented Apr 18, 2024

在用 apt 安装好 pip 后, 尝试使用 pip 安装任何包都报这个错

root@localhost:~/gpad-servo# pip install jnius
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/pip", 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

经查阅 https://devv.ai/search?threadId=dj2aesdmqdc0 后,尝试给环境变量 ANDROID_DATA 设置为

export ANDROID_DATA=/data/data/com.nightmare.code/files/home/

后可正常使用 pip

@Douraben
Copy link

已得帮助!感谢分享!

@mengyanshou
Copy link
Contributor

我有个疑问,是在哪个地方安装pip呢,是第一个终端界面还是VS Code界面打开后呢

@DBinK
Copy link
Author

DBinK commented May 13, 2024

我有个疑问,是在哪个地方安装pip呢,是第一个终端界面还是VS Code界面打开后呢

vscode里的终端

@DBinK DBinK changed the title 无法使用pip安装包,在设置 ANDROID_DATA 环境变量后可修复 无法使用pip安装Python库,在设置 ANDROID_DATA 环境变量后可修复 May 13, 2024
@mengyanshou
Copy link
Contributor

收到,我今天尽量做一些测试,然后修复

@mengyanshou
Copy link
Contributor

测试pip install jnius能够复现,已修复,代码晚些提交,下个版本更新会带上

@mengyanshou
Copy link
Contributor

经过测试,只有jnius这类包会有这个问题,因为这类包需要对应的环境变量,例如numpy``pandas就没有这个问题,自行配置环境变量即可,我刚配置完ANDROID_DATA,它还是会要JDK_HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants