【问题标题】:Using paramiko on a android python App在 android python App 上使用 paramiko
【发布时间】:2016-05-18 00:19:33
【问题描述】:

我正在使用 buildozer 编译 Python 应用程序,我可以毫无问题地构建 APK。 在我提出的要求中:

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = sqlite3,kivy,datetime,plyer,paramiko

但是应用程序没有启动。如果我评论“import paramiko”这一行,应用程序就会启动,但显然不是我的选择。在 PC 上 paramiko 工作没有问题。 我知道,例如,sqlite3 必须在 kivy 的要求之前出现,对吧?我尝试了许多不同的选项,例如“sqlite3,paramiko,kivy,datetime,plyer”或“sqlite3,kivy,paramiko,datetime,plyer”。我该怎么办?

版本:

Not sure if i did correctly but... I enable developer option on my phone, the adb logcat, run the App on the phone then I got: 

    05-18 10:21:49.755 20436 20436 V python  : metadata fullscreen is0
05-18 10:21:49.966 20436 20449 I python  : Starting audio thread
05-18 10:21:50.053 20436 20452 I python  : presplash-fit is null
05-18 10:21:50.054 20436 20452 I python  : presplash (fit=null) mx=0,450000,my=0,710000
05-18 10:21:50.073 20436 20452 I python  : Initialize Python for Android
05-18 10:21:50.275 20436 20452 I python  : ['/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/site-python']
05-18 10:21:50.275 20436 20452 I python  : Android path ['/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python27.zip', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages', '/storage/emulated/0/com.doatlanticoaopacifico.dap', '/storage/emulated/0/com.doatlanticoaopacifico.dap/_applibs']
05-18 10:21:50.275 20436 20452 I python  : Android kivy bootstrap done. __name__ is __main__
05-18 10:21:50.275 20436 20452 I python  : Run user program, change dir and execute main.py
05-18 10:21:50.592 20436 20452 I python  : [INFO              ] [Logger      ] Record log in /storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/logs/kivy_16-05-18_5.txt
05-18 10:21:50.593 20436 20452 I python  : [INFO              ] [Kivy        ] v1.9.1
05-18 10:21:50.593 20436 20452 I python  : [INFO              ] [Python      ] v2.7.2 (default, May 17 2016, 21:38:56) 
05-18 10:21:50.593 20436 20452 I python  : [GCC 4.8]
05-18 10:21:50.669 20436 20452 I python  : [INFO              ] [Factory     ] 179 symbols loaded
05-18 10:21:51.682 20436 20452 I python  :  /data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom
05-18 10:21:51.683 20436 20452 I python  :  (ImportError: No module named cdrom)
05-18 10:21:51.728 20436 20452 I python  : [INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
05-18 10:21:53.083 20436 20452 I python  : [INFO              ] [Window      ] Provider: pygame
05-18 10:21:53.101 20436 20452 I python  : [INFO              ] [GL          ] OpenGL version <OpenGL ES 3.0 V@140.0 AU@  (GIT@I14a17c7611)>
05-18 10:21:53.102 20436 20452 I python  : [INFO              ] [GL          ] OpenGL vendor <Qualcomm>
05-18 10:21:53.102 20436 20452 I python  : [INFO              ] [GL          ] OpenGL renderer <Adreno (TM) 306>
05-18 10:21:53.103 20436 20452 I python  : [INFO              ] [GL          ] OpenGL parsed version: 3, 0
05-18 10:21:53.105 20436 20452 I python  : [INFO              ] [GL          ] Texture max size <4096>
05-18 10:21:53.106 20436 20452 I python  : [INFO              ] [GL          ] Texture max units <16>
05-18 10:21:53.174 20436 20452 I python  : [INFO              ] [Shader      ] program: <--From Vertex Shader:
05-18 10:21:53.174 20436 20452 I python  : --From Fragment Shader:
05-18 10:21:53.174 20436 20452 I python  : Link was successful.>
05-18 10:21:54.114 20436 20452 I python  : [INFO              ] [Support     ] Android install hooks
05-18 10:21:54.116 20436 20452 I python  : [INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
05-18 10:21:54.142 20436 20452 I python  : [INFO              ] [Text        ] Provider: pygame
05-18 10:21:54.440 20436 20452 I python  :  Traceback (most recent call last):
05-18 10:21:54.441 20436 20452 I python  :    File "/home/awulll/dapapp/.buildozer/android/app/main.py", line 12, in <module>
05-18 10:21:54.442 20436 20452 I python  :    File "/home/awulll/dapapp/.buildozer/android/app/rotinas.py", line 11, in <module>
05-18 10:21:54.443 20436 20452 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/__init__.py", line 30, in <module>
05-18 10:21:54.444 20436 20452 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/transport.py", line 59, in <module>
05-18 10:21:54.445 20436 20452 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/ecdsakey.py", line 26, in <module>
05-18 10:21:54.445 20436 20452 I python  :  ImportError: No module named ecdsa
05-18 10:21:54.516 20436 20452 I python  : Python for android ended.

第 2 版:

使用 adb logcat | grep python(我可以从终端复制):

    enter code here05-18 10:40:32.601 26849 26864 W linker  : /data/app/com.doatlanticoaopacifico.dap-1/lib/arm/libpython2.7.so: is missing DT_SONAME will use basename as a replacement: "libpython2.7.so"
05-18 10:40:32.625 26849 26864 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/_io.so: is missing DT_SONAME will use basename as a replacement: "_io.so"
05-18 10:40:32.642 26849 26864 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/unicodedata.so: is missing DT_SONAME will use basename as a replacement: "unicodedata.so"
05-18 10:40:32.682 26849 26864 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/_sqlite3.so: is missing DT_SONAME will use basename as a replacement: "_sqlite3.so"
05-18 10:40:32.688 26849 26864 I python  : Starting audio thread
05-18 10:40:32.709 26849 26882 I python  : Initialize Python for Android
05-18 10:40:32.974 26849 26882 I python  : ['/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/site-python']
05-18 10:40:32.974 26849 26882 I python  : Android path ['/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python27.zip', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload', '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages', '/storage/emulated/0/com.doatlanticoaopacifico.dap', '/storage/emulated/0/com.doatlanticoaopacifico.dap/_applibs']
05-18 10:40:32.974 26849 26882 I python  : Android kivy bootstrap done. __name__ is __main__
05-18 10:40:32.974 26849 26882 I python  : Run user program, change dir and execute main.py
05-18 10:40:33.119 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/_hashlib.so: is missing DT_SONAME will use basename as a replacement: "_hashlib.so"
05-18 10:40:33.331 26849 26882 I python  : [ERROR             ] Error when copying logo directory
05-18 10:40:33.331 26849 26882 I python  : Traceback (most recent call last):
05-18 10:40:33.331 26849 26882 I python  :   File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/__init__.py", line 301, in <module>
05-18 10:40:33.331 26849 26882 I python  :   File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/shutil.py", line 205, in copytree
05-18 10:40:33.331 26849 26882 I python  : Error: [('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-64.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-64.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-64.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-512.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-512.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-512.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-256.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-256.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-256.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-32.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-32.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-32.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-24.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-24.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-24.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-128.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-128.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-128.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-48.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-48.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-48.png'"), ('/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo/kivy-icon-16.png', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-16.png', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon/kivy-icon-16.png'"), '/data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/data/logo', '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon', "[Errno 1] Operation not permitted: '/storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/icon'"]
05-18 10:40:33.353 26849 26882 I python  : [WARNING           ] [Config      ] Older configuration version detected (0 instead of 14)
05-18 10:40:33.354 26849 26882 I python  : [WARNING           ] [Config      ] Upgrading configuration in progress.
05-18 10:40:33.372 26849 26882 I python  : [INFO              ] [Logger      ] Record log in /storage/emulated/0/com.doatlanticoaopacifico.dap/.kivy/logs/kivy_16-05-18_0.txt
05-18 10:40:33.373 26849 26882 I python  : [INFO              ] [Kivy        ] v1.9.1
05-18 10:40:33.373 26849 26882 I python  : [INFO              ] [Python      ] v2.7.2 (default, May 17 2016, 21:38:56) 
05-18 10:40:33.373 26849 26882 I python  : [GCC 4.8]
05-18 10:40:33.391 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/_ctypes.so: is missing DT_SONAME will use basename as a replacement: "_ctypes.so"
05-18 10:40:33.436 26849 26882 I python  : [INFO              ] [Factory     ] 179 symbols loaded
05-18 10:40:34.414 26849 26882 I python  :  /data/user/0/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom
05-18 10:40:34.415 26849 26882 I python  :  (ImportError: No module named cdrom)
05-18 10:40:34.460 26849 26882 I python  : [INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
05-18 10:40:35.702 26849 26882 I python  : [INFO              ] [Window      ] Provider: pygame
05-18 10:40:35.718 26849 26882 I python  : [INFO              ] [GL          ] OpenGL version <OpenGL ES 3.0 V@140.0 AU@  (GIT@I14a17c7611)>
05-18 10:40:35.718 26849 26882 I python  : [INFO              ] [GL          ] OpenGL vendor <Qualcomm>
05-18 10:40:35.719 26849 26882 I python  : [INFO              ] [GL          ] OpenGL renderer <Adreno (TM) 306>
05-18 10:40:35.720 26849 26882 I python  : [INFO              ] [GL          ] OpenGL parsed version: 3, 0
05-18 10:40:35.721 26849 26882 I python  : [INFO              ] [GL          ] Texture max size <4096>
05-18 10:40:35.722 26849 26882 I python  : [INFO              ] [GL          ] Texture max units <16>
05-18 10:40:35.791 26849 26882 I python  : [INFO              ] [Shader      ] program: <--From Vertex Shader:
05-18 10:40:35.791 26849 26882 I python  : --From Fragment Shader:
05-18 10:40:35.791 26849 26882 I python  : Link was successful.>
05-18 10:40:36.725 26849 26882 I python  : [INFO              ] [Support     ] Android install hooks
05-18 10:40:36.727 26849 26882 I python  : [INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
05-18 10:40:36.746 26849 26882 I python  : [INFO              ] [Text        ] Provider: pygame
05-18 10:40:36.819 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/lib-dynload/_ssl.so: is missing DT_SONAME will use basename as a replacement: "_ssl.so"
05-18 10:40:36.953 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/Crypto/Util/_counter.so: is missing DT_SONAME will use basename as a replacement: "_counter.so"
05-18 10:40:36.960 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/Crypto/Cipher/_AES.so: is missing DT_SONAME will use basename as a replacement: "_AES.so"
05-18 10:40:36.969 26849 26882 W linker  : /data/data/com.doatlanticoaopacifico.dap/files/lib/python2.7/site-packages/Crypto/Cipher/_DES3.so: is missing DT_SONAME will use basename as a replacement: "_DES3.so"
05-18 10:40:37.005 26849 26882 I python  :  Traceback (most recent call last):
05-18 10:40:37.006 26849 26882 I python  :    File "/home/awulll/dapapp/.buildozer/android/app/main.py", line 12, in <module>
05-18 10:40:37.006 26849 26882 I python  :    File "/home/awulll/dapapp/.buildozer/android/app/rotinas.py", line 11, in <module>
05-18 10:40:37.007 26849 26882 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/__init__.py", line 30, in <module>
05-18 10:40:37.008 26849 26882 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/transport.py", line 59, in <module>
05-18 10:40:37.009 26849 26882 I python  :    File "/home/awulll/dapapp/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/ecdsakey.py", line 26, in <module>
05-18 10:40:37.010 26849 26882 I python  :  ImportError: No module named ecdsa
05-18 10:40:37.080 26849 26882 I python  : Python for android ended.
05-18 10:40:37.157 26987 27003 I ActivityManager: Process com.doatlanticoaopacifico.dap:python (pid 26849) has died

【问题讨论】:

  • 我应该添加任何android权限吗?我只是添加相机。 ftp有什么特别的吗?
  • 来自 github repo:“它完全是用 Python 编写的(尽管它依赖于第三方 C 包装器......”可能在 p4a 中没有配方,所以它没有编译因此该应用程序很糟糕。但是,请尝试logcat 以获取有关它的更多信息并编辑您的问题,如果它是不同的东西。哦,甚至...尝试“互联网”权限。
  • 正如 KeyWeeUsr 所说,paramiko 或其依赖项之一需要一个配方。有人在 p4a github 上的一个问题中遇到了同样的问题,所以也许他们会提供必要的食谱。我认为 cffi 是最终需要配方的东西。
  • 我真的认为这不是食谱问题。如果我有食谱问题,我能获得 APK 吗?我的一个已经建成,我可以安装在我的 Android 上,但它就是无法启动。我也尝试了 INTERNET 权限,但没有任何反应。其他人也有同样的问题(groups.google.com/forum/#!msg/kivy-users/1tWnZHDQuOs/…),但我不知道他到底做了什么——我也在那里问过他。我会尝试 adb logcat,只需要先学习如何使用,呵呵。好吧,以后我希望有更多的信息。

标签: android python kivy paramiko kivy-language


【解决方案1】:

我明白了!

我在要求上添加了 ecdsa:

# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = sqlite3,kivy,datetime,plyer,ecdsa,paramiko

我不知道这是否有任何区别,但我将权限保留为:

android.permissions = INTERNET,ACCESS_NETWORK_STATE,CAMERA

谢谢大家!

【讨论】:

  • 您可以在 logcat 中清楚地看到:05-18 10:21:54.445 20436 20452 I python : ImportError: No module named ecdsa:P
  • 是的!我花了一些时间了解 adb logcat 以及如何为我的手机启用开发人员调试,但在那之后就很容易了。感谢@KeyWeeUsr 的提示!
  • 提示 #2:如果您有更多时间并且不确定是否满足要求中的所有内容,请对该软件包进行全新安装以查看依赖项(以及 deps 的 deps 等)并检查pip list... 或执行pip show &lt;package&gt;,但它只会返回当前包的deps
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-19
  • 2018-01-23
  • 1970-01-01
  • 2018-07-20
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
相关资源
最近更新 更多