On Sun, Feb 24, 2013 at 8:16 PM, Ondřej Čertík <ondrej.certik@gmail.com> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <dynamicgl@gmail.com> wrote:
> Hi All
>      When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
> found out even a simple "import numpy" may lead to program failed with
> following exception:
> "AttributeError: 'module' object has no attribute 'sys'
> After a poking around some codes I noticed /numpy/core/__init__.py has a
> line 'del sys' at the bottom. After I commented this line, and repacked the
> whole program, It ran fine.
> I also noticed this 'del sys' didn't exist on numpy 1.6.2
> I am curious why this 'del sys' should be here and whether it is safe to
> omit it. Thanks.

The "del sys" line was introduced in the commit:


and it seems to me that it is needed so that the numpy.core namespace is not
cluttered by it.

Can you post the full stacktrace of your program (and preferably some
how to reproduce the problem)? It should become clear where the problem is.


I have run into issues with doing "del sys" before, but usually with respect to my pythonrc file.  Because the import of sys has already happened, python won't let you import the module again in the same namespace (in my case, the runtime environment).  I don't know how the frozen binaries work, but maybe something along those lines is happening?

Ben Root