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

Error - 'str' object has no attribute 'write' #7

Open
RogerGladstone opened this issue May 17, 2017 · 14 comments
Open

Error - 'str' object has no attribute 'write' #7

RogerGladstone opened this issue May 17, 2017 · 14 comments

Comments

@RogerGladstone
Copy link

I receive this error after the lookup and selecting the file icon. I have attached a file of the command line output. What am I doing wrong?

Thanks for your help.
Roger

Python Error - AudioJack (May 16, 2017).txt

@Blue9
Copy link
Owner

Blue9 commented May 19, 2017

This is an unusual error, and it looks like it has to do with youtube-dl. Try updating youtube-dl and re-downloading the FFmpeg binaries, and see if you still get the error.

@Blue9 Blue9 closed this as completed May 30, 2017
@gupta-utkarsh
Copy link

This issue is still present. I updated youtube-dl and FFmpeg and still, the error is present.

@Blue9
Copy link
Owner

Blue9 commented Oct 11, 2017

What OS are you using? Do you always get this error, or only with certain settings (custom tags, custom path, etc.)?

@RogerGladstone
Copy link
Author

RogerGladstone commented Oct 26, 2017 via email

@Blue9
Copy link
Owner

Blue9 commented Nov 24, 2017

Thank you for the detailed breakdown! I'm thinking that something is going wrong in application.py, but there are a few try-catch statements after line 58 so it's difficult to pinpoint where the error is occurring. Try replacing application.py with the copy I've attached (rename the extension to .py, GitHub doesn't allow attaching .py files directly) and you should get a more detailed error report.

application.txt

@Blue9 Blue9 reopened this Nov 24, 2017
@RogerGladstone
Copy link
Author

RogerGladstone commented Nov 24, 2017 via email

@Blue9
Copy link
Owner

Blue9 commented Nov 24, 2017

Looks like youtube-dl expects sys.stderr.buffer to be a BufferedWriter object, but for some reason, your console returns a string object. Where are you running the program from (cmd, PowerShell, etc.)?

Also, what is returned when you run the following code?

import sys
print(sys.stderr.buffer)

@RogerGladstone
Copy link
Author

RogerGladstone commented Nov 25, 2017 via email

@Blue9
Copy link
Owner

Blue9 commented Nov 25, 2017

You have to run the code in the Python shell. In cmd, first type in py, then press enter. You should see a message telling you your Python version and some other info (make sure this is Python 3+, if it's not, then try running python instead). Type in the first line (import sys) and press enter, and then type in sys.stderr.buffer and press enter.

If that doesn't work, then save the two lines of code as a .py file and run it as you would run any Python file.

@RogerGladstone
Copy link
Author

RogerGladstone commented Nov 25, 2017 via email

@Blue9
Copy link
Owner

Blue9 commented Dec 5, 2017

I'm not exactly sure what is causing this problem; I suggest you open an issue over on youtube-dl and see if they can help. In the meantime, does using PowerShell or another terminal prevent the error?

@bunny-pot
Copy link

bunny-pot commented Jan 13, 2019

I'm having the same issue on macOS ver 10.13.6.
output of sys.stderr.buffer is <_io.BufferedWriter name='<stderr>'>

@cmot17
Copy link

cmot17 commented May 19, 2019

@bunny-pot same exact issue on MacOS Mojave 10.14.4. Has anybody found a fix for this?

@cmot17
Copy link

cmot17 commented May 19, 2019

Here is the output using the modified application.py file:

$ python3 launcher.py
[INFO   ] [Logger      ] Record log in /Users/cmot17/.kivy/logs/kivy_19-05-19_1.txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Loader      ] using a thread pool of 2 workers
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <gl>
[INFO   ] [GL          ] OpenGL version <b'2.1 ATI-2.8.38'>
[INFO   ] [GL          ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'AMD Radeon RX Vega 56 OpenGL Engine'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <b'1.20'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [Base        ] Start application main loop
[INFO   ] [Clipboard   ] Provider: sdl2(['clipboard_nspaste'] ignored)
[youtube] XbGs_qK2PQA: Downloading webpage
[youtube] XbGs_qK2PQA: Downloading video info webpage
Notified current thread
/Users/cmot17/Downloads/AudioJack-GUI
[youtube] XbGs_qK2PQA: Downloading webpage
[youtube] XbGs_qK2PQA: Downloading video info webpage
[download] XbGs_qK2PQA.webm has already been downloaded
[download] 100% of 5.80MiB
[ffmpeg] Destination: XbGs_qK2PQA.mp3
 Exception in thread Thread-10:
 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 265, in run_ffmpeg
     FFmpegPostProcessor.run_ffmpeg(self, path, out_path, opts)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 239, in run_ffmpeg
     self.run_ffmpeg_multiple_files([path], out_path, opts)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
     raise FFmpegPostProcessorError(msg)
 youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError: Unknown encoder 'libmp3lame'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 336, in run
     self.run_ffmpeg(path, new_path, acodec, more_opts)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 267, in run_ffmpeg
     raise AudioConversionError(err.msg)
 youtube_dl.postprocessor.common.AudioConversionError: Unknown encoder 'libmp3lame'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2054, in post_process
     files_to_delete, info = pp.run(info)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 339, in run
     'audio conversion failed: ' + e.msg)
 youtube_dl.utils.PostProcessingError: audio conversion failed: Unknown encoder 'libmp3lame'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
     self.run()
   File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
     self._target(*self._args, **self._kwargs)
   File "/Users/cmot17/Downloads/AudioJack-GUI/audiojack_gui.py", line 175, in _select
     self.local_search.select(index, path=self.path)
   File "/Users/cmot17/Downloads/AudioJack-GUI/application.py", line 63, in select
     self.file = self.audiojack.select(self.selection, path=path)
   File "/Users/cmot17/Downloads/AudioJack-GUI/audiojack.py", line 46, in select
     info = self.ydl.extract_info(entry['url'])
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 807, in extract_info
     return self.process_ie_result(ie_result, download, extra_info)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 861, in process_ie_result
     return self.process_video_result(ie_result, download=download)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 1642, in process_video_result
     self.process_info(new_info)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 1989, in process_info
     self.post_process(filename, info_dict)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2056, in post_process
     self.report_error(e.msg)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 624, in report_error
     self.trouble(error_message, tb)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 577, in trouble
     self.to_stderr(message)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 526, in to_stderr
     self._write_string(output, self._err_file)
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 505, in _write_string
     write_string(s, out=out, encoding=self.params.get('encoding'))
   File "/usr/local/lib/python3.7/site-packages/youtube_dl/utils.py", line 1500, in write_string
     out.buffer.write(byt)
 AttributeError: 'str' object has no attribute 'write'

EDIT:
Here is more info:

$ python3
Python 3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stderr.buffer
<_io.BufferedWriter name='<stderr>'>

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

5 participants