Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
linux apache python cgi error: failed to get random numbers to initialize Python

My old CentOS 5 apache server can run Perl script CGI without any problem.

# cat t1.cgi
#!/usr/local/bin/perl

use CGI;
my $cgi = CGI->new();
print $cgi->header;

print "Test\n"; 



# GET HTTP://www.example.com/cgi/t1.cgi
Test

python scripts can be run under shell without any problem:

# cat t2.cgi
#!/usr/local/bin/python3

print("Content-Type: text/html\n")


print("hello!")

# python3 t2.cgi                                                                                                                                                              
Content-Type: text/html

hello!

but failed as a python cgi script:

# GET http://www.example.com/cgi/t2.cgi
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
500 Internal Server Error
</BODY>
</HTML>

apache error logs show the error was:

Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
Python runtime state: preinitialized

Premature end of script headers: t2.cgi

any idea will be appreciated!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

fixed it by

mknod -m 444 /dev/random
chmod 444 /dev/urandom

my old centos don't have /dev/random, and the default file mode for urandom was 600, read only by root.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda