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

AttributeError: 'str' object has no attribute 'write' en android #22108

Closed
python-ab opened this issue Aug 15, 2019 · 3 comments
Closed

AttributeError: 'str' object has no attribute 'write' en android #22108

python-ab opened this issue Aug 15, 2019 · 3 comments

Comments

@python-ab
Copy link

@python-ab python-ab commented Aug 15, 2019

I am trying to download audio and videos using kivy. the code works fine in windows and ubuntu but it generates an error in android.

this is the code:

import youtube_dl

import kivy
kivy.require('1.11.0')

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout

from kivy.config import Config
Config.set('graphics', 'width', 400)
Config.set('graphics', 'height', 200)

class Contenedor_01(BoxLayout):

def descargarA(self):
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
            }],
    }

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        ydl.download(['https://www.youtube.com/watch?v=2j3x0VYnehg'])

class MainApp(App):
def build(self):
return Contenedor_01()

if name == 'main':
MainApp().run()

me genera este error:
I/python (20086): Android kivy bootstrap done. name is main
I/python (20086): AND: Ran string
I/python (20086): Run user program, change dir and execute entrypoint
I/python (20086): [WARNING] [Config ] Older configuration version detected (0 instead of 21)
I/python (20086): [WARNING] [Config ] Upgrading configuration in progress.
I/python (20086): [INFO ] [Logger ] Record log in /data/user/0/org.test.downloadmeapp/files/app/.kivy/logs/kivy_19-08-15_0.txt
I/python (20086): [INFO ] [Kivy ] v1.11.0
I/python (20086): [INFO ] [Kivy ] Installed at "/data/user/0/org.test.downloadmeapp/files/app/_python_bundle/site-packages/kivy/init.pyc"
I/python (20086): [INFO ] [Python ] v3.7.1 (default, Aug 15 2019, 15:27:31)
I/python (20086): [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
I/python (20086): [INFO ] [Python ] Interpreter at "android_python"
I/python (20086): [INFO ] [Factory ] 184 symbols loaded
I/python (20086): [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
I/python (20086): [INFO ] [Window ] Provider: sdl2
I/python (20086): [INFO ] [GL ] Using the "OpenGL ES 2" graphics system
I/python (20086): [INFO ] [GL ] Backend used
I/python (20086): [INFO ] [GL ] OpenGL version <b'OpenGL ES 3.1 V@140.0 (GIT@Iec24cdb30f)'>
I/python (20086): [INFO ] [GL ] OpenGL vendor <b'Qualcomm'>
I/python (20086): [INFO ] [GL ] OpenGL renderer <b'Adreno (TM) 405'>
I/python (20086): [INFO ] [GL ] OpenGL parsed version: 3, 1
I/python (20086): [INFO ] [GL ] Texture max size <16384>
I/python (20086): [INFO ] [GL ] Texture max units <16>
I/python (20086): [INFO ] [Window ] auto add sdl2 input provider
I/python (20086): [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
I/python (20086): [INFO ] [Text ] Provider: sdl2
I/python (20086): [WARNING] [Base ] Unknown provider
I/python (20086): [INFO ] [Base ] Start application main loop
I/python (20086): [INFO ] [GL ] NPOT texture support is available
I/python (20086): [INFO ] [Base ] Leaving application in progress...
I/python (20086): Traceback (most recent call last):
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/app/main.py", line 38, in
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/app.py", line 855, in run
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", line 504, in runTouchApp
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", line 746, in mainloop
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", line 478, in _mainloop
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", line 342, in idle
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", line 327, in dispatch_input
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", line 233, in post_dispatch_input
I/python (20086): File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/init.py", line 1378, in on_motion
I/python (20086): File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/init.py", line 1394, in on_touch_down
I/python (20086): File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/uix/widget.py", line 549, in on_touch_down
I/python (20086): File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/uix/behaviors/button.py", line 151, in on_touch_down
I/python (20086): File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
I/python (20086): File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
I/python (20086): File "kivy/_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/lang/builder.py", line 64, in custom_callback
I/python (20086): File "/data/data/org.test.downloadmeapp/files/app/main.kv", line 4, in
I/python (20086): on_press: root.descargarA()
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/app/main.py", line 29, in descargarA
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", line 2010, in download
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", line 796, in extract_info
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 530, in extract
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", line 1668, in _real_extract
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 794, in _download_webpage
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", line 274, in _download_webpage_handle
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 660, in _download_webpage_handle
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 602, in _request_webpage
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 922, in report_download_webpage
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", line 914, in to_screen
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", line 502, in to_screen
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", line 516, in to_stdout
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", line 505, in _write_string
I/python (20086): File "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/utils.py", line 3084, in write_string
I/python (20086): AttributeError: 'str' object has no attribute 'write'
I/python (20086): Python for android ended.

I can't solve this problem

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 15, 2019

English only.

@dstftw dstftw closed this Aug 15, 2019
@python-ab
Copy link
Author

@python-ab python-ab commented Aug 15, 2019

I am trying to download audio and videos using kivy. the code works fine in windows and ubuntu but generates an error in android.

This is the code:

importar youtube_dl

import kivy
kivy.require ('1.11.0')

from kivy.app import App
de kivy.uix.boxlayout import BoxLayout

desde kivy.config import Config
Config.set ('gráficos', 'ancho', 400)
Config.set ('gráficos', 'alto', 200)

clase Contenedor_01 (BoxLayout):

def descargarA(self):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=2j3x0VYnehg'])

clase MainApp (aplicación):
def build (self):
return Contenedor_01 ()

if name == ' main ':
MainApp (). run ()

I get this error:

I / python (20086): Android kivy bootstrap hecho. el nombre es I / python principal
(20086): AND: Ran string
I / python (20086): Ejecute el programa de usuario, cambie el directorio y ejecute el punto de entrada
I / python (20086): [ADVERTENCIA] [Config] Versión de configuración anterior detectada (0 en su lugar de 21)
I / python (20086): [ADVERTENCIA] [Config] Actualización de la configuración en progreso.
I / python (20086): [INFO] [Logger] Registro de registro en /data/user/0/org.test.downloadmeapp/files/app/.kivy/logs/kivy_19-08-15_0.txt
I / python (20086 ): [INFO] [Kivy] v1.11.0
I / python (20086): [INFO] [Kivy] instalado en "/data/user/0/org.test.downloadmeapp/files/app/_python_bundle/site-packages/ kivy /init .pyc "
I / python (20086): [INFO] [Python] v3.7.1 (predeterminado, 15 de agosto de 2019, 15:27:31)
I / python (20086): [Clang 6.0.2 (https: // android.googlesource.com/toolchain/clang 183abd29fc496f55
I / python (20086): [INFO] [Python] Intérprete en "android_python"
I / python (20086): [INFO] [Factory] 184 símbolos cargados
I / python (20086) : [INFO] [Imagen] Proveedores: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignorado)
I / python (20086): [INFO] [Window] Proveedor: sdl2
I / python (20086): [INFO] [GL ] Utilizando el sistema gráfico "OpenGL ES 2"
I / python (20086): [INFO] [GL] Backend utilizado
I / python (20086): [INFO] [GL] OpenGL versión <b'OpenGL ES 3.1 V@140.0 (GIT @ Iec24cdb30f) '>
I / python (20086): [INFO] [GL] Proveedor de OpenGL <b'Qualcomm '>
I / python (20086): [INFO] [GL] Procesador de OpenGL <b'Adreno (TM) 405'>
I / python (20086): [INFO] [GL] Versión analizada de OpenGL: 3, 1
I / python (20086): [INFO] [GL] Tamaño máximo de textura <16384>
I / python (20086): [INFO] [GL] Unidades máximas de textura <16>
I / python (20086): [INFO] [Ventana] auto agregar proveedor de entrada sdl2
I / python (20086): [INFO] [Ventana] teclado virtual no permitido, modo único, no acoplado
I / python (20086): [INFO] [Texto] Proveedor: sdl2
I / python (20086): [ADVERTENCIA] [Base] Proveedor desconocido
I / python (20086): [INFO] [Base] Iniciar el bucle principal de la aplicación
I / python (20086): [INFO] [GL] El soporte de textura NPOT está disponible
I / python (20086): [INFO] [Base] Dejando la aplicación en progreso ...
I / python (20086): Traceback (última llamada):
I / python (20086): Archivo "/ home / abrahan / Escritorio /prueba/.buildozer/android/app/main.py ", línea 38, en
I / python (20086): Archivo" /home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python- instala / DownLoadMeApp / kivy / app.py ", línea 855, en ejecución
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 504, en runTouchApp
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", línea 746, en mainloop
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/window_sdl2.py", línea 478, en _mainloop
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 342, en inactivo
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 327, en dispatch_input
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/base.py", línea 233, en post_dispatch_input
I / python (20086) : Archivo "kivy / _event.pyx", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/ python-installs / DownLoadMeApp / kivy / core / window / init .py ", línea 1378, en on_motion
I / python (20086): Archivo" kivy / _event.pyx ", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/core/window/ init .py", línea 1394, en on_touch_down
I / python (20086): Archivo "kivy / _event.pyx", línea 707, en kivy._event.EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android /platform/build/build/python-installs/DownLoadMeApp/kivy/uix/widget.py ", línea 549, en on_touch_down
I / python (20086): Archivo" kivy / _event.pyx ", línea 707, en kivy._event .EventDispatcher.dispatch
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/kivy/uix/behaviors/button.py", línea 151,en on_touch_down
I / python (20086): archivo "kivy / _event.pyx", línea 703, en kivy._event.EventDispatcher.dispatch
I / python (20086): archivo "kivy / _event.pyx", línea 1214, en kivy._event .EventObservers.dispatch
I / python (20086): Archivo "kivy / _event.pyx", línea 1098, en kivy._event.EventObservers._dispatch
I / python (20086): Archivo "/ home / abrahan / Escritorio / prueba /. buildozer / android / platform / build / build / python-installs / DownLoadMeApp / kivy / lang / builder.py ", línea 64, en custom_callback
I / python (20086): Archivo" /data/data/org.test.downloadmeapp/ files / app / main.kv ", línea 4, en
I / python (20086): on_press: root.descargarA ()
I / python (20086): File" /home/abrahan/Escritorio/prueba/.buildozer/android/ app / main.py ", línea 29,en descargarA
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 2010, en descarga
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 796, en extract_info
I / python (20086) : Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 530, en extracto
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", línea 1668, en _real_extract
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 794, en _download_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/youtube.py", línea 274, en _download_webpage_handle
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 660, en _download_webpage_handle
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 602,en _request_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 922, en report_download_webpage
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/extractor/common.py", línea 914, en to_screen
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 502, en la pantalla
I / python (20086 ): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 516, en to_stdout
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/YoutubeDL.py", línea 505, en _write_string
I / python (20086): Archivo "/home/abrahan/Escritorio/prueba/.buildozer/android/platform/build/build/python-installs/DownLoadMeApp/youtube_dl/utils.py", línea 3084, en write_string
I / python (20086) : AttributeError: el objeto 'str' no tiene atributo 'write'
I / python (20086): Python para Android finalizó.

I can't solve this problem

@adarsh1783
Copy link

@adarsh1783 adarsh1783 commented Jun 23, 2020

I am getting the same error. Have anybody solve this issue ?? Or even found a workaround to this issue.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.