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

Windows 10 x64 - Fatal Python error: Py_Initialize: unable to load the file system codec #10372

Open
Smiley43210 opened this issue Aug 17, 2016 · 16 comments
Labels

Comments

@Smiley43210
Copy link

@Smiley43210 Smiley43210 commented Aug 17, 2016

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.08.17. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2016.08.17

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

C:\path\to\youtube-dl>youtube-dl.exe -v
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00003a38 (most recent call first):
<end of log>

Description of your issue, suggested solution and other information

Similar issue:
I found #10053, which reports the same problem, but was closed because the user had placed it in C:\Windows\System32. I did not place mine in that location.

Additional notes:

  • I downloaded the executable file just prior to executing, so it is the latest version
  • Windows 10 x64 machine
  • Microsoft Visual C++ 2010 redistributable package is installed
  • The machine was recently upgraded to Windows 10, and prior to the upgrade, youtube-dl functioned just fine
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 17, 2016

  1. What is the C:\path\to\youtube-dl?
  2. What is the output of where youtube-dl.exe?
@Smiley43210
Copy link
Author

@Smiley43210 Smiley43210 commented Aug 18, 2016

  1. The path to youtube-dl is C:\Users\REDACTED\Downloads\Youtube. I'm using the executable from within the folder that it resides in, so it does not (and never has) exist in the PATH.
C:\Users\REDACTED\Downloads\Youtube>where youtube-dl.exe
C:\Users\REDACTED\Downloads\Youtube\youtube-dl.exe
@Slaymeister
Copy link

@Slaymeister Slaymeister commented Oct 16, 2016

Same issue in Windows 10 x64. Tried in the cmd.exe interpreter and powershell v5.1. I'm running it out of the current directory. Path includes "c:\Python34;c:\python34\scripts".

c:\..>  .\youtube-dl.exe -v
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00005464 (most recent call first):
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Oct 17, 2016

@Slaymeister Could you remove the Python 3.4 installation and try again? They may conflict with each other.

@Hrxn
Copy link

@Hrxn Hrxn commented Oct 17, 2016

What happens if you boot into safe mode and run youtube-dl.exe there?

@Slaymeister
Copy link

@Slaymeister Slaymeister commented Oct 18, 2016

I removed Python 3.4 and had the same error.
Running in safe mode also produced the same error.

@Hrxn
Copy link

@Hrxn Hrxn commented Oct 20, 2016

Check with Tasklist (or Procexp) for running processes and services, try closing or deactivating non-necessary stuff and try again..

Maybe post the output here..

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jan 20, 2017

I got this today. It seems a random error...
init-failure
In all invocations youtube-dl.exe is the same file. G:\ is a mounted Virtualbox share.

@r13s
Copy link

@r13s r13s commented Jan 21, 2017

I have such an error only when I try to run the youtube-dl.exe from any directory other than the one in which the youtube-dl.exe resides.

Windows 10 x64

@romaincointepas
Copy link

@romaincointepas romaincointepas commented Sep 30, 2017

I can reproduce by simply signing youtube-dl.exe using SignTool.

Ex:

  1. Download youtube-dl.exe then run it in many different ways (from same folder, etc.). Always works.
  2. Sign it using signtool.exe sign ...
  3. Run it with in many different ways, always fails with the following error:
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Relevant:

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 30, 2017

@romaincointepas
Copy link

@romaincointepas romaincointepas commented Sep 30, 2017

@yan12125 are you sure youtube-dl.exe is signed?

When I run signtool.exe verify youtube-dl.exe, I get SignTool Error: No signature found.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 30, 2017

@romaincointepas
Copy link

@romaincointepas romaincointepas commented Sep 30, 2017

@yan12125 Oh got it.

I'm shipping youtube-dl as part of an Electron app, and as part of the packaging process I'm signing the main executable and all embedded executables. I've just discovered that in order to sign a py2exe executable, I will need to build youtube-dl myself and detach the library from the exe loader (as explained here: https://medium.com/@bjoernstiel/code-signing-py2exe-executables-a222c0d06d3f).

I'm currently trying to figure out how to build youtube-dl on Windows, but that shouldn't be a problem.

I just thought I would mention this specific cause as it ends up failing in the exact same way as this issue mentions.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 30, 2017

Thanks for the link! Maybe we can sign youtube-dl.exe when building it. Seems it requires buying a certificate to get a valid signature? I'm not sure if getting another signature is worth it - we already have PGP signatures.

If there's really a need, could you open a new issue? This issue targets unmodified youtube-dl.exe

@romaincointepas
Copy link

@romaincointepas romaincointepas commented Sep 30, 2017

@yan12125 New issue created: #14367

Just to clarify here as well, the official youtube-dl release should not be signed (that's really not the problem, and you would encounter the same problem to sign it anyway). The solution simply require an additional build of youtube-dl for windows (one that separate the exe loader and the library, that's it).

@ytdl-org ytdl-org deleted a comment from cjjmccray Apr 21, 2018
@ytdl-org ytdl-org deleted a comment from yafrica Apr 21, 2018
@ytdl-org ytdl-org deleted a comment from vinaybond Apr 21, 2018
@ytdl-org ytdl-org locked and limited conversation to collaborators Apr 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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