如何让Buildozer通过pip成功将socket安装到手机app中

How to get Buildozer to successfully install socket into mobile app via pip

我的问题是我无法使用 Buildozer 创建 Python Kivy 移动应用程序,除非它无法安装依赖项之一,socket。我在 buildozer.spec 文件中列出了套接字,它编译为以下错误。我还尝试在没有套接字作为依赖项的情况下编译应用程序,当任何套接字命令为 运行 时,它会编译但会使移动应用程序崩溃。 我应该如何成功地允许套接字编译成 buildozer 移动应用程序?

* https://pypi.org/simple/socket/
Fetching project page and analyzing links: https://pypi.org/simple/socket/
Getting page https://pypi.org/simple/socket/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/socket/" in the cache
Request header has "max_age" as 0, cache bypassed
https://pypi.org:443 "GET /simple/socket/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/socket/: 404 Client Error: Not Found for url: https://pypi.org/simple/socket/ - skipping
Skipping link: not a file: https://pypi.org/simple/socket/
Given no hashes to check 0 links for project 'socket': discarding no candidates
ERROR: Could not find a version that satisfies the requirement socket (from versions: none)
ERROR: No matching distribution found for socket
Exception information:
Traceback (most recent call last):
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 341, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _merge_into_criterion
    raise RequirementsConflicted(criterion)
pip._vendor.resolvelib.resolvers.RequirementsConflicted: Requirements conflict: SpecifierRequirement('socket')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 127, in resolve
    result = self._result = resolver.resolve(
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 473, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 343, in resolve
    raise ResolutionImpossible(e.criterion.information)
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('socket'), parent=None)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
    status = self.run(options, args)
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 318, in run
    requirement_set = resolver.resolve(
  File "/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 136, in resolve
    raise error from e
pip._internal.exceptions.DistributionNotFound: No matching distribution found for socket
Removed build tracker: '/tmp/pip-req-tracker-a_rq6ha8'


  STDERR:

# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myappv4 --bootstrap=sdl2 --requirements=python3,kivy,socket --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/ubuntu/raspberry_shake_alert_system/mobile_app/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
# ENVIRONMENT:
#     SHELL = '/bin/bash'
#     PWD = '/home/ubuntu/raspberry_shake_alert_system/mobile_app'
#     LOGNAME = 'ubuntu'
#     XDG_SESSION_TYPE = 'tty'
#     MOTD_SHOWN = 'pam'
#     HOME = '/home/ubuntu'
#     LANG = 'C.UTF-8'
#     LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
#     SSH_CONNECTION = '122.58.154.180 49383 10.0.0.16 11337'
#     LESSCLOSE = '/usr/bin/lesspipe %s %s'
#     XDG_SESSION_CLASS = 'user'
#     TERM = 'xterm'
#     LESSOPEN = '| /usr/bin/lesspipe %s'
#     USER = 'ubuntu'
#     SHLVL = '1'
#     XDG_SESSION_ID = '912'
#     XDG_RUNTIME_DIR = '/run/user/1001'
#     SSH_CLIENT = '122.58.154.180 49383 11337'
#     XDG_DATA_DIRS = '/usr/local/share:/usr/share:/var/lib/snapd/desktop'
#     PATH = '/home/ubuntu/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
#     DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1001/bus'
#     SSH_TTY = '/dev/pts/0'
#     _ = '/home/ubuntu/.local/bin/buildozer'
#     OLDPWD = '/home/ubuntu/raspberry_shake_alert_system'
#     PACKAGES_PATH = '/home/ubuntu/.buildozer/android/packages'
#     ANDROIDSDK = '/home/ubuntu/.buildozer/android/platform/android-sdk'
#     ANDROIDNDK = '/home/ubuntu/.buildozer/android/platform/android-ndk-r19c'
#     ANDROIDAPI = '27'
#     ANDROIDMINAPI = '21'
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

socket 是一个 python 内置模块,不能通过 pip 安装。

I have also attempted to compile the app without socket as a dependency, which compiles but crashes the mobile app when any socket command is run

为什么您认为崩溃是由于缺少套接字模块造成的?