Форум сайта python.su
Здравствуйте, столкнулся с проблемой при использовании scipy.weave. У меня стоит Python 2.7.3 модули numpy 1.6.2 и scipy 0.10.1 ставил при помощи pip. Так же стоит mirco soft visual studio 2008 c/c++ (ставил vcsetup.exe c сайта microsoft там же бесплатно зарегистрировал) и mingw (ставил с помощью mingw-get-inst-20120426.exe затрудняюсь сказать версию, после установки добавил переменную в PATH путь C:\MinGW\bin и перезагрузился)
Возьмем скрипт-пример из C:\Python27\Lib\site-packages\scipy\weave\examples например array3d.py
его исходный код:
""" A simple example to show how to access a 3D numpy array. One example shows how to access the numpy array using blitz type converters and the other shows how it can be done without using blitz by accessing the numpy array data directly. """ import scipy.weave as weave from scipy.weave import converters import numpy def create_array(): """Creates a simple 3D numpy array with unique values at each location in the matrix. """ rows, cols, depth = 2, 3, 4 arr = numpy.zeros((rows, cols, depth), 'i') count = 0 for i in range(rows): for j in range(cols): for k in range(depth): arr[i,j,k] = count count += 1 return arr def pure_inline(arr): """Prints the given 3D array by accessing the raw numpy data and without using blitz converters. Notice the following: 1. '\\n' to escape generating a newline in the C++ code. 2. rows, cols = Narr[0], Narr[1]. 3. Array access using arr[(i*cols + j)*depth + k]. """ code = """ int rows = Narr[0]; int cols = Narr[1]; int depth = Narr[2]; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { printf("img[%3d][%3d]=", i, j); for (int k=0; k< depth; ++k) { printf(" %3d", arr[(i*cols + j)*depth + k]); } printf("\\n"); } } """ weave.inline(code, ['arr']) def blitz_inline(arr): """Prints the given 3D array by using blitz converters which provides a numpy-like syntax for accessing the numpy data. Notice the following: 1. '\\n' to escape generating a newline in the C++ code. 2. rows, cols = Narr[0], Narr[1]. 3. Array access using arr(i, j, k). """ code = """ int rows = Narr[0]; int cols = Narr[1]; int depth = Narr[2]; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { printf("img[%3d][%3d]=", i, j); for (int k=0; k< depth; ++k) { printf(" %3d", arr(i, j, k)); } printf("\\n"); } } """ weave.inline(code, ['arr'], type_converters=converters.blitz) def main(): arr = create_array() print("numpy:") print(arr) print("Pure Inline:") pure_inline(arr) print("Blitz Inline:") blitz_inline(arr) if __name__ == '__main__': main()
numpy: [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]] Pure Inline: No module named msvccompiler in numpy.distutils; trying from distutils creating c:\docume~1\m@d_ph~1\locals~1\temp\M@D_PHISICER\python27_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e Missing compiler_cxx fix for MSVCCompiler Found executable C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe Traceback (most recent call last): File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 105, in <module> main() File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 98, in main pure_inline(arr) File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 57, in pure_inline weave.inline(code, ['arr']) File "C:\Python27\lib\site-packages\scipy\weave\inline_tools.py", line 355, in inline **kw) File "C:\Python27\lib\site-packages\scipy\weave\inline_tools.py", line 482, in compile_function verbose=verbose, **kw) File "C:\Python27\lib\site-packages\scipy\weave\ext_tools.py", line 367, in compile verbose = verbose, **kw) File "C:\Python27\lib\site-packages\scipy\weave\build_tools.py", line 272, in build_extension setup(name = module_name, ext_modules = [ext],verbose=verb) File "C:\Python27\lib\site-packages\numpy\distutils\core.py", line 186, in setup return old_setup(**new_attr) File "C:\Python27\lib\distutils\core.py", line 162, in setup raise SystemExit, error CompileError: error: Bad file descriptor
weave.inline(code, ['arr'])
weave.inline(code, ['arr'], type_converters=converters.blitz)
weave.inline(code, ['arr'], compiler='gcc')
weave.inline(code, ['arr'], type_converters=converters.blitz,compiler='gcc')
numpy: [[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] [[12 13 14 15] [16 17 18 19] [20 21 22 23]]] Pure Inline: creating c:\docume~1\m@d_ph~1\locals~1\temp\M@D_PHISICER\python27_intermediate\compiler_ceffdcf12be28532cafcaa87f8ac2f76 Found executable C:\MinGW\bin\g++.exe Traceback (most recent call last): File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 105, in <module> main() File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 98, in main pure_inline(arr) File "C:\Python32\Lib\site-packages\scipy\weave\examples\array3d.py", line 57, in pure_inline weave.inline(code, ['arr'], compiler='gcc') File "C:\Python27\lib\site-packages\scipy\weave\inline_tools.py", line 355, in inline **kw) File "C:\Python27\lib\site-packages\scipy\weave\inline_tools.py", line 482, in compile_function verbose=verbose, **kw) File "C:\Python27\lib\site-packages\scipy\weave\ext_tools.py", line 367, in compile verbose = verbose, **kw) File "C:\Python27\lib\site-packages\scipy\weave\build_tools.py", line 272, in build_extension setup(name = module_name, ext_modules = [ext],verbose=verb) File "C:\Python27\lib\site-packages\numpy\distutils\core.py", line 186, in setup return old_setup(**new_attr) File "C:\Python27\lib\distutils\core.py", line 162, in setup raise SystemExit, error CompileError: error: Bad file descriptor
Отредактировано med_phisiker (Сен. 29, 2012 14:40:31)
Офлайн