[python-win32] Importing tempfile (or random) results in disaster...

Tim Golden mail at timgolden.me.uk
Thu May 31 18:09:24 CEST 2012


On 31/05/2012 14:40, Kevin Horn wrote:
> I'm setting up a new machine (Win7) and one of the first things I
> thought I'd do is install Python, distribute, pip, virtualenv, etc.
> 
> However, I can't seem to get that far.
> 
> When trying to install distribute (using distribute_setup.py), I get the
> following traceback:
> 
> Traceback (most recent call last):
>   File "distribute_setup.py", line 20, in <module>
>     import tempfile
>   File "C:\Python27\lib\tempfile.py", line 34, in <module>
>     from random import Random as _Random
>   File "C:\Python27\lib\random.py", line 881, in <module>
>     _inst = Random()
>   File "C:\Python27\lib\random.py", line 97, in __init__
>     self.seed(x)
>   File "C:\Python27\lib\random.py", line 111, in seed
>     a = long(_hexlify(_urandom(16)), 16)
> WindowsError: [Error -2146893818] Invalid Signature
> 
> "Huh," I thought.  "That's weird".
> 
> A little googling turned up this bug:
> 
> http://bugs.python.org/issue13524
> 
> Which has the same traceback, but purports to have something to do with
> not passing the right environment to the subprocess module (and is
> marked as "Wontfix").
> 
> But this doesn't seem to me to be the problem, as I'm not using the
> subprocess module.  In fact, here is the minimal reproducible example on
> my machine:
> 
> tfile.py:
> import tempfile
> 
> 
> 
> That's it.  Just "import tempfile" and Python comes to a screeching
> halt.  In fact, "import random" does this as well, and either one will
> also cause the traceback from within the interactive interpreter.
> 
> What's going on here?  Is this a Win7 thing?  I have 2.7.3 working on XP
> and Vista without a problem.

Are you inside a virtualenv? There was a venv bug recently
which manifested itself in a similar way. Hang on...

Have a look around here (not sure exactly which part of the
thread to pull at) and see if anything rings bells.

  http://mail.python.org/pipermail/python-dev/2012-March/118233.html

TJG


More information about the python-win32 mailing list