Yes, this one again "ImportError: No module named multiarray"

I've been using Numpy/Scipy for >5 years so know a little on how to get around them. Recently, I've needed to either freeze or create executables with tools such as PyInstaller, Cython, Py2exe and others on both Windows (XP 32-bit, 7 64-bit) and Ubuntu (12.04) Linux (64-bit). The test program (which runs perfectly with the Python interpreter) is very simple:
import numpy
def main(): print numpy.array([12, 23, 34, 45, 56, 67, 78, 89, 90]) return
if __name__ == '__main__': main()
The software versions are Python 2.7.3, Numpy 1.7.0, and Scipy 0.11. The "import numpy" causes an "ImportError: No module named multiarray". After endless Googling, I am none the wiser about what (really) causes the ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in <module> import add_newdocs File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module> from numpy.lib import add_newdoc File "C:\Python27\lib\site-packages\numpy\lib__init__.py", line 4, in <module> from type_check import * File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module> import numpy.core.numeric as _nx File "C:\Python27\lib\site-packages\numpy\core__init__.py", line 5, in <module> import multiarray ImportError: No module named multiarray.
Could someone shed some light on this - please? Thx.

multiarray is an extension module that lives within numpy/core, that is, when, "import multiarray" is called, (and it's the first imported extension module in numpy), multiarray.ext (ext being dll on Windows I guess), gets dynamically loaded.
"No module named multiarray" is indicating problems with your freeze setup. Most of these tools don't support locally imported extension modules.
Does this help you get oriented on your problem?
A
On Tue, Mar 12, 2013 at 1:01 PM, Dinesh B Vadhia dineshbvadhia@hotmail.comwrote:
** I've been using Numpy/Scipy for >5 years so know a little on how to get around them. Recently, I've needed to either freeze or create executables with tools such as PyInstaller, Cython, Py2exe and others on both Windows (XP 32-bit, 7 64-bit) and Ubuntu (12.04) Linux (64-bit). The test program (which runs perfectly with the Python interpreter) is very simple:
import numpy
def main(): print numpy.array([12, 23, 34, 45, 56, 67, 78, 89, 90]) return
if __name__ == '__main__': main()
The software versions are Python 2.7.3, Numpy 1.7.0, and Scipy 0.11. The "import numpy" causes an "ImportError: No module named multiarray". After endless Googling, I am none the wiser about what (really) causes the ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in
<module> import add_newdocs File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module> from numpy.lib import add_newdoc File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module> from type_check import * File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module> import numpy.core.numeric as _nx File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 5, in <module> import multiarray ImportError: No module named multiarray.
Could someone shed some light on this - please? Thx.
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Does that mean numpy won't work with freeze/create_executable type of tools or is there a workaround?
From: Aron Ahmadia Sent: Tuesday, March 12, 2013 6:17 AM To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] Yes,this one again "ImportError: No module named multiarray"
multiarray is an extension module that lives within numpy/core, that is, when, "import multiarray" is called, (and it's the first imported extension module in numpy), multiarray.ext (ext being dll on Windows I guess), gets dynamically loaded.
"No module named multiarray" is indicating problems with your freeze setup. Most of these tools don't support locally imported extension modules.
Does this help you get oriented on your problem?
A
On Tue, Mar 12, 2013 at 1:01 PM, Dinesh B Vadhia dineshbvadhia@hotmail.com wrote:
I've been using Numpy/Scipy for >5 years so know a little on how to get around them. Recently, I've needed to either freeze or create executables with tools such as PyInstaller, Cython, Py2exe and others on both Windows (XP 32-bit, 7 64-bit) and Ubuntu (12.04) Linux (64-bit). The test program (which runs perfectly with the Python interpreter) is very simple:
import numpy
def main(): print numpy.array([12, 23, 34, 45, 56, 67, 78, 89, 90]) return
if __name__ == '__main__': main()
The software versions are Python 2.7.3, Numpy 1.7.0, and Scipy 0.11. The "import numpy" causes an "ImportError: No module named multiarray". After endless Googling, I am none the wiser about what (really) causes the ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in <module> import add_newdocs File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module> from numpy.lib import add_newdoc File "C:\Python27\lib\site-packages\numpy\lib__init__.py", line 4, in <module> from type_check import * File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module> import numpy.core.numeric as _nx File "C:\Python27\lib\site-packages\numpy\core__init__.py", line 5, in <module> import multiarray ImportError: No module named multiarray.
Could someone shed some light on this - please? Thx.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Tue, Mar 12, 2013 at 7:05 AM, Dinesh B Vadhia dineshbvadhia@hotmail.com wrote:
Does that mean numpy won't work with freeze/create_executable type of tools or is there a workaround?
I've used numpy with py2exe and py2app out of the box with no issues ( actually, there is an issue with too much stuff getting bundled up, but it works)
ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in
<module>
This indicates that your code is importing the numpy that's inside the system installation -- it should be using one in your app bundle.
What bundling tool are you using? How did you install python/numpy? What does your bundling tol config look like? And, of course, version numbers of everything.
-Chris

Hi Chris Darn! It worked this morning and I don't know why.
Focused on PyInstaller because it creates a single executable. Testing on all major versions of Windows (32-bit and 64-bit), Linux and OSX. The problem OS is unsurprisingly, Windows XP (SP3).
Numpy was upgraded to the mkl-version and maybe that did the trick. Tried to replicate on an identical Windows XP machine using the standard sourceforge distribution but that resulted in a pyinstaller error.
Anyway, using the latest releases of all software ie. Python 2.7.3, Numpy 1.7.0, Scipy 0.11.0, PyInstaller 2.0.
Will post back if run into problems again. Best ...
-------------------------------------------------- From: "Chris Barker - NOAA Federal" chris.barker@noaa.gov Sent: Tuesday, March 12, 2013 2:50 PM To: "Discussion of Numerical Python" numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] Yes,this one again "ImportError: No module named multiarray"
On Tue, Mar 12, 2013 at 7:05 AM, Dinesh B Vadhia dineshbvadhia@hotmail.com wrote:
Does that mean numpy won't work with freeze/create_executable type of tools or is there a workaround?
I've used numpy with py2exe and py2app out of the box with no issues ( actually, there is an issue with too much stuff getting bundled up, but it works)
ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in
<module>
This indicates that your code is importing the numpy that's inside the system installation -- it should be using one in your app bundle.
What bundling tool are you using? How did you install python/numpy? What does your bundling tol config look like? And, of course, version numbers of everything.
-Chris
--
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov

Glad you got it working! For those who might be interested, the distinction between the example I linked to and packaging tools like PyInstaller or py2exe, is that NumpyBuiltinExamplehttps://github.com/patmarion/NumpyBuiltinExampleuses static linking to embed numpy as a builtin module. At runtime, there is no dynamic loading, and there is no filesystem access. The technique is targeted at HPC or embedded systems where you might want to avoid touching the filesystem, or avoid dynamic loading.
Pat
On Thu, Mar 14, 2013 at 2:08 AM, Dinesh B Vadhia dineshbvadhia@hotmail.comwrote:
Hi Chris Darn! It worked this morning and I don't know why.
Focused on PyInstaller because it creates a single executable. Testing on all major versions of Windows (32-bit and 64-bit), Linux and OSX. The problem OS is unsurprisingly, Windows XP (SP3).
Numpy was upgraded to the mkl-version and maybe that did the trick. Tried to replicate on an identical Windows XP machine using the standard sourceforge distribution but that resulted in a pyinstaller error.
Anyway, using the latest releases of all software ie. Python 2.7.3, Numpy 1.7.0, Scipy 0.11.0, PyInstaller 2.0.
Will post back if run into problems again. Best ...
From: "Chris Barker - NOAA Federal" chris.barker@noaa.gov Sent: Tuesday, March 12, 2013 2:50 PM To: "Discussion of Numerical Python" numpy-discussion@scipy.org Subject: Re: [Numpy-discussion] Yes,this one again "ImportError: No module named multiarray"
On Tue, Mar 12, 2013 at 7:05 AM, Dinesh B Vadhia dineshbvadhia@hotmail.com wrote:
Does that mean numpy won't work with freeze/create_executable type of tools or is there a workaround?
I've used numpy with py2exe and py2app out of the box with no issues ( actually, there is an issue with too much stuff getting bundled up, but it works)
ImportError let alone what the solution is. The Traceback, similar to others found on the web, is:
Traceback (most recent call last): File "test.py", ... File "C:\Python27\lib\site-packages\numpy__init__.py", line 154, in
<module>
This indicates that your code is importing the numpy that's inside the system installation -- it should be using one in your app bundle.
What bundling tool are you using? How did you install python/numpy? What does your bundling tol config look like? And, of course, version numbers of everything.
-Chris
--
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (4)
-
Aron Ahmadia
-
Chris Barker - NOAA Federal
-
Dinesh B Vadhia
-
Pat Marion