Need Help as Problems with youtube_dl in pycharm

My code is:

# filename is downloadpractice.py

from
__future__ import unicode_literals
import youtube_dl

ydl_opts = {
'format':'bestaudio/best',
'postprocessors': [{
'key':'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '128',
}],
'outtmpl': u'/home/mistu/Desktop/youtube/%(title)s.%(ext)s'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=Mn0zj8Ql7Fs&t=205s'])

 

When I run this within pycharm community edition I got this result in the terminal:

/home/mistu/PycharmProjects/Environment/bin/python /home/mistu/PycharmProjects/PyQt5_Training/downloadpractice.py
[youtube] Mn0zj8Ql7Fs: Downloading webpage
[youtube] Mn0zj8Ql7Fs: Downloading MPD manifest
[download] /home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.m4a has already been downloaded
[download] 100% of 4.42MiB
[ffmpeg] Correcting container in "/home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.m4a"
ERROR: file:/home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.temp.m4a: Invalid argument
Traceback (most recent call last):
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2065, in post_process
files_to_delete, info = pp.run(info)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 574, in run
self.run_ffmpeg(filename, temp_filename, options)
File "/home/mistu/PycharmProjects/Environment/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 "/home/mistu/PycharmProjects/Environment/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: file:/home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.temp.m4a: Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mistu/PycharmProjects/PyQt5_Training/downloadpractice.py", line 13, in <module>
ydl.download(['https://www.youtube.com/watch?v=Mn0zj8Ql7Fs&t=205s'])
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2019, in download
url, force_generic_extractor=self.params.get('force_generic_extractor', False))
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
return self.process_ie_result(ie_result, download, extra_info)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 863, in process_ie_result
return self.process_video_result(ie_result, download=download)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 1644, in process_video_result
self.process_info(new_info)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2000, in process_info
self.post_process(filename, info_dict)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2067, in post_process
self.report_error(e.msg)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 625, in report_error
self.trouble(error_message, tb)
File "/home/mistu/PycharmProjects/Environment/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 595, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: file:/home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.temp.m4a: Invalid argument

Process finished with exit code 1

 

But while I run this program outside Pycharm, i.e. in the terminal by passing the command---->

python3 downloadpractice.py  

it worked just fine. I don't know what i did wrong. Please help me out.

 

shared file id for the jetbrain support is :  2020_08_05_DLZmyXTfLL2DFQNF

4 comments
Comment actions Permalink

Hi,

Have you tried running /home/mistu/PycharmProjects/Environment/bin/python /home/mistu/PycharmProjects/PyQt5_Training/downloadpractice.py from the terminal? What's the result?

0
Comment actions Permalink

If I try the below thing, worked just fine.....

mistu@LinuxMint:~/Desktop/youtube$ python3 downloadpractice.py
[youtube] Mn0zj8Ql7Fs: Downloading webpage
[youtube] Mn0zj8Ql7Fs: Downloading MPD manifest
[download] /home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.m4a has already been downloaded
[download] 100% of 4.42MiB
[ffmpeg] Correcting container in "/home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.m4a"
[ffmpeg] Destination: /home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.mp3
Deleting original file /home/mistu/Desktop/youtube/Download Youtube video using youtube_dl in Python.m4a (pass -k to keep)
mistu@LinuxMint:~/Desktop/youtube$

 

But if I try, your thing...--->

mistu@LinuxMint:~$ /home/mistu/PycharmProjects/Environment/bin/python /home/mistu/PycharmProjects/PyQt5_Training/downloadpractice.py
bash: /home/mistu/PycharmProjects/Environment/bin/python: No such file or directory
mistu@LinuxMint:~$

 

Gives errors! see the screenshot of the folder containing "python" files.

0
Comment actions Permalink

That's odd. How did you create this environment?

If you configure your system interpreter in PyCharm (run which python3 to get the full path to python executable) and then run your code with it, does it work?

0
Comment actions Permalink

I am using PyCharm for a long time. It never happened before. Possibly new update to PyCharm 2020.2 may be the problem.

Well ! the problem is gone now after reinstalling PyCharm 2020.2 (Portable version) and Creating the new environment for the project.

I was previously using only one Environment for all of my projects. But now I will use one Environment for one project.

 Thanks to your quick support and very friendly reply.

0

Please sign in to leave a comment.