Python Forum
Python Error with youtube-dl - Any Help?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Error with youtube-dl - Any Help?
#1
This is a very new (two days) Win10 install on a clean disk.

And a new install of the latest Python release.

And an install of Python 2.7 because someone suggested that might help but it didn't.

I use youtube-dl from the command prompt - from Powershell - and it won't run but instead I get this error message:


PS C:\Windows\system32> youtube-dl
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'


Can anyone help with that please?
Reply
#2
Quote:Python 2.7 because someone suggested that might help
stay away from python 2.7 on all new development, always use latest release.
Reply
#3
Follow this Python 3.6/3.7 and pip installation under Windows
Then is shall work like this,i test isolated(virtual environment venv) as already have youtube-dl.
(forum_env) E:\div_code\forum_env
# Test pip
λ pip -V
pip 19.0.3 from e:\div_code\forum_env\lib\site-packages\pip (python 3.7)

(forum_env) E:\div_code\forum_env
# Install youtube-dl
λ pip install --upgrade youtube-dl
Collecting youtube-dl
  Downloading ...
Successfully installed youtube-dl-2019.9.28

(forum_env) E:\div_code\forum_env
# Test that it work,example to MP3 highest quality
λ youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 "https://www.youtube.com/watch?v=HW_EmCGc6DI&list=RDHW_EmCGc6DI&start_radio=1"

[download] Downloading playlist: Mix - Halsey - Nightmare in the Live Lounge
[youtube:playlist] playlist Mix - Halsey - Nightmare in the Live Lounge: Collected 281 video ids (downloading 281 of them)
.....
[download] Destination: Halsey - Nightmare in the Live Lounge-HW_EmCGc6DI.webm
[download] 100% of 3.91MiB in 00:01
[ffmpeg] Destination: Halsey - Nightmare in the Live Lounge-HW_EmCGc6DI.mp3
Deleting original file Halsey - Nightmare in the Live Lounge-HW_EmCGc6DI.webm (pass -k to keep)
Reply
#4
Thank you very much for that. I followed it to the letter and apparently I've got a viable python installation now.

I did get an error at the end of the test download:

ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.

Can I do that within the powershell python thing?

Thank you very much for that help. It's great. :)
Reply
#5
(Sep-30-2019, 09:16 PM)abrogard Wrote: I did get an error at the end of the test download:

ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
Download Zeranoe FFmpeg Builds.
The simplest can be if you unsure of adding to Windows path.
Put to together with youtube-dl.exe it's in eg python37\Scripts folder.
Then look like this in root python/Scripts folder:
youtube-dl.exe
ffprobe.exe
ffplay.exe
ffmpeg.exe
Quote:Can I do that within the powershell python thing?
Yes you can do same commands in powershell,i use cmder because it look better and all Linux commands that i am used to work.
Like ls which like better than dir,both work it just that cmder add more stuff.
Here Script folder of virtual environment.
[Image: Z9Tht6.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make a bot in pycharm for youtube for automatically adding python comments kodek2222 1 2,027 Jan-21-2021, 12:47 PM
Last Post: Aspire2Inspire
  How to check if video has been deleted or removed in youtube using python Prince_Bhatia 14 11,584 Feb-21-2020, 04:33 AM
Last Post: jehoshua
  How to get python to download YouTube videos in the background? Pythenx 11 10,605 Mar-25-2019, 04:57 AM
Last Post: samsonite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020