Quantcast

a question about freeze on numpy 1.7.0

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

a question about freeze on numpy 1.7.0

Gelin Yan
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.

Regards

gelin yan



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Ondřej Čertík
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Benjamin Root-2


On Sun, Feb 24, 2013 at 8:16 PM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej

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

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Gelin Yan
In reply to this post by Ondřej Čertík


On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi Ondrej

    I attached two files here for demonstration. you need cx_freeze to build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example works with numpy 1.6.2. Thanks.

Regards

gelin yan


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

numpytest.py (122 bytes) Download Attachment
setup.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Bradley M. Froehle
I can reproduce with NumPy 1.7.0, but I'm not convinced the bug lies within NumPy.

The exception is not being raised on the `del sys` line.  Rather it is being raised in numpy.__init__:

  File "/home/bfroehle/.local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
    exec code in m.__dict__
  File "numpytest.py", line 1, in <module>
    import numpy
  File "/home/bfroehle/.local/lib/python2.7/site-packages/numpy/__init__.py", line 147, in <module>
    from core import *
AttributeError: 'module' object has no attribute 'sys'

This is because, somehow, `'sys' in numpy.core.__all__` returns True in the cx_Freeze context but False in the regular Python context.

-Brad


On Sun, Feb 24, 2013 at 10:49 PM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi Ondrej

    I attached two files here for demonstration. you need cx_freeze to build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example works with numpy 1.6.2. Thanks.

Regards

gelin yan


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Gelin Yan


On Mon, Feb 25, 2013 at 3:53 PM, Bradley M. Froehle <[hidden email]> wrote:
I can reproduce with NumPy 1.7.0, but I'm not convinced the bug lies within NumPy.

The exception is not being raised on the `del sys` line.  Rather it is being raised in numpy.__init__:

  File "/home/bfroehle/.local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
    exec code in m.__dict__
  File "numpytest.py", line 1, in <module>
    import numpy
  File "/home/bfroehle/.local/lib/python2.7/site-packages/numpy/__init__.py", line 147, in <module>
    from core import *
AttributeError: 'module' object has no attribute 'sys'

This is because, somehow, `'sys' in numpy.core.__all__` returns True in the cx_Freeze context but False in the regular Python context.

-Brad


On Sun, Feb 24, 2013 at 10:49 PM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi Ondrej

    I attached two files here for demonstration. you need cx_freeze to build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example works with numpy 1.6.2. Thanks.

Regards

gelin yan


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Hi Bradley

    So is it supposed to be a bug of cx_freeze? Any work around for that except omit 'del sys'? If the answer is no, I may consider submit a ticket on cx_freeze site. Thanks

Regards

gelin yan

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Bradley M. Froehle
I submitted a bug report (and patch) to cx_freeze.  You can follow up with them at http://sourceforge.net/p/cx-freeze/bugs/36/.

-Brad


On Mon, Feb 25, 2013 at 12:06 AM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 3:53 PM, Bradley M. Froehle <[hidden email]> wrote:
I can reproduce with NumPy 1.7.0, but I'm not convinced the bug lies within NumPy.

The exception is not being raised on the `del sys` line.  Rather it is being raised in numpy.__init__:

  File "/home/bfroehle/.local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
    exec code in m.__dict__
  File "numpytest.py", line 1, in <module>
    import numpy
  File "/home/bfroehle/.local/lib/python2.7/site-packages/numpy/__init__.py", line 147, in <module>
    from core import *
AttributeError: 'module' object has no attribute 'sys'

This is because, somehow, `'sys' in numpy.core.__all__` returns True in the cx_Freeze context but False in the regular Python context.

-Brad


On Sun, Feb 24, 2013 at 10:49 PM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi Ondrej

    I attached two files here for demonstration. you need cx_freeze to build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example works with numpy 1.6.2. Thanks.

Regards

gelin yan


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Hi Bradley

    So is it supposed to be a bug of cx_freeze? Any work around for that except omit 'del sys'? If the answer is no, I may consider submit a ticket on cx_freeze site. Thanks

Regards

gelin yan

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about freeze on numpy 1.7.0

Gelin Yan


On Mon, Feb 25, 2013 at 4:09 PM, Bradley M. Froehle <[hidden email]> wrote:
I submitted a bug report (and patch) to cx_freeze.  You can follow up with them at http://sourceforge.net/p/cx-freeze/bugs/36/.

-Brad


On Mon, Feb 25, 2013 at 12:06 AM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 3:53 PM, Bradley M. Froehle <[hidden email]> wrote:
I can reproduce with NumPy 1.7.0, but I'm not convinced the bug lies within NumPy.

The exception is not being raised on the `del sys` line.  Rather it is being raised in numpy.__init__:

  File "/home/bfroehle/.local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
    exec code in m.__dict__
  File "numpytest.py", line 1, in <module>
    import numpy
  File "/home/bfroehle/.local/lib/python2.7/site-packages/numpy/__init__.py", line 147, in <module>
    from core import *
AttributeError: 'module' object has no attribute 'sys'

This is because, somehow, `'sys' in numpy.core.__all__` returns True in the cx_Freeze context but False in the regular Python context.

-Brad


On Sun, Feb 24, 2013 at 10:49 PM, Gelin Yan <[hidden email]> wrote:


On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík <[hidden email]> wrote:
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan <[hidden email]> 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:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

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
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi Ondrej

    I attached two files here for demonstration. you need cx_freeze to build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example works with numpy 1.6.2. Thanks.

Regards

gelin yan


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Hi Bradley

    So is it supposed to be a bug of cx_freeze? Any work around for that except omit 'del sys'? If the answer is no, I may consider submit a ticket on cx_freeze site. Thanks

Regards

gelin yan

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Hi Brad

   please feel free to check it http://sourceforge.net/p/cx-freeze/bugs/36/

someone from cx_freeze has replied it. Thanks again

Regards

gelin yan

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...