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

no module named tty #1165

Closed
sm-jalali-f opened this issue Nov 10, 2017 · 5 comments
Closed

no module named tty #1165

sm-jalali-f opened this issue Nov 10, 2017 · 5 comments

Comments

@sm-jalali-f
Copy link

i'm running testapp in your repository but when run application it crashe.
log cat error show this :
11-10 21:06:50.949 17674 17698 I python : Traceback (most recent call last):
11-10 21:06:50.949 17674 17698 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/app/main.py", line 5, in
11-10 21:06:50.949 17674 17698 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/platform/build/dists/kivyAndcai/private/lib/python2.7/site-packages/pythonforandroid/recipes/android/init.py", line 1, in
11-10 21:06:50.950 17674 17698 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/platform/build/dists/kivyAndcai/private/lib/python2.7/site-packages/pythonforandroid/recipe.py", line 10, in
11-10 21:06:50.950 17674 17698 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/platform/build/dists/kivyAndcai/private/lib/python2.7/site-packages/sh.py", line 96, in
11-10 21:06:50.950 17674 17698 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/platform/build/build/other_builds/python2/armeabi-v7a/python2/python-install/lib/python2.7/pty.py", line 11, in
11-10 21:06:50.950 17674 17698 I python : ImportError: No module named tty

how to fix it???

@inclement
Copy link
Member

The tty module isn't included in the apk as a minor optimisation (almost nothing uses it). You can un-blacklist it if necessary using the whitelist options of buildozer/python-for-android. The term to whilelist is tty.pyo.

Also, you say you're using one of the testapps, but the traceback seems to indicate the code is trying to use the sh module. Is this something you added to the testapp, or did you change anything else away from the parameters in the repository?

@sm-jalali-f
Copy link
Author

My problem is solved. i remove sh library.
but i write my program that receive intent in android app.
my code is:

from kivy.app import App
from pythonforandroid.recipes.android.src.android.broadcast import BroadcastReceiver

class MyApp(App):
    # def __init__(self, **kwargs):
    #     super().__init__(**kwargs)
    #     print("init")

    def build(self):
        print("build")
        self.br = BroadcastReceiver(self.on_broadcast, actions=['new_picture_added'])
        self.br.start()
        

    def on_broadcast(self, context, intent):
        extras = intent.getExtras()
        pictureAddress = str(extras.get('picture_address'))
        print(pictureAddress)
        self.out.write("onBroadcast\n")

    def on_pause(self):
        self.br.stop()
        print("onPause")
        self.out.write("onPause")
        return super(MyApp, self).on_pause()


    def on_resume(self):
        self.br.start()
        print("onResume")
        self.out.write("onResume")
        super(MyApp, self).on_resume()



if __name__ == '__main__':
    MyApp().run()

and add python-for-android in requirement on spec file like this:
requirements = kivy,python-for-android
but when build and run android application with this command:
sudo buildozer android debug deploy run logcat
when running this error occured:
11-12 21:49:53.843 2872 2909 I python : Traceback (most recent call last):
11-12 21:49:53.843 2872 2909 I python : File "/home/mohamad/PycharmProjects/kivyDeepLearn/.buildozer/android/app/main.py", line 5, in
11-12 21:49:53.843 2872 2909 I python : ImportError: No module named pythonforandroid.recipes.android.src.android.broadcast
11-12 21:49:53.861 2872 2909 I python : Python for android ended.

what is my mistake?

@inclement
Copy link
Member

python-for-android is a build tools for Android, you don't need or want it in your app itself. You just want the android module, so include that in your requirements and import from there.

@sm-jalali-f
Copy link
Author

I change requirements line to this but not work. and error occured again
requirements = kivy,android

@inclement
Copy link
Member

Please post the details of the error on the kivy-users mailing list.

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

2 participants