Rápli András
Rápli András

Reputation: 3923

Python random number generator error. WindowsError: [Error -2146893818] Invalid Signature

What is wrong with the built-in python RNG? This line keeps crashing my application

File "C:\Python27\lib\random.py", line 113, in seed
    a = long(_hexlify(_urandom(2500)), 16)
WindowsError: [Error -2146893818] Invalid Signature

The error only occurs when I try to run python from a web application with PHP's proc_open().

Upvotes: 0

Views: 616

Answers (1)

Rápli András
Rápli András

Reputation: 3923

Okay, it turned out to be a PHP problem, not OS level, so highly unlikely you could've helped without the code, but i'll leave this here if anyone faces the same problem.

This is an environment variable issue. When calling proc_open(), PHP uses operating system level environment variables unless you specify $env as the fifth argument. The error in my case was that I remembered incorrectly that $env has to be specified, and I used an empty array as its value, which overtook OS level path definitions. Removed $env and $cwd and it worked like a charm.

Upvotes: 0

Related Questions