我是新手,我不知道是什么导致了这个错误。该错误也发生在其他代码示例上,因此它不是特定代码。我正在使用 Windows 7 和 python 2.7。感谢任何能提供帮助的人!
>>> from scipy import weave
>>> a = 1
>>> weave.inline('printf("%d\\n",a);',['a'])
No module named msvccompiler in numpy.distutils; trying from distutils
Looking for python27.dll
Looking for python27.dll
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
weave.inline('printf("%d\\n",a);',['a'])
File "C:\Python27\lib\scipy\weave\inline_tools.py", line 366, in inline
**kw)
File "C:\Python27\lib\scipy\weave\inline_tools.py", line 496, in compile_function
verbose=verbose, **kw)
File "C:\Python27\lib\scipy\weave\ext_tools.py", line 373, in compile
verbose=verbose, **kw)
File "C:\Python27\lib\scipy\weave\build_tools.py", line 279, in build_extension
setup(name=module_name, ext_modules=[ext],verbose=verb)
File "C:\Python27\lib\site-packages\numpy\distutils\core.py", line 169, in setup
return old_setup(**new_attr)
File "C:\Python27\lib\distutils\core.py", line 166, in setup
raise SystemExit, "error: " + str(msg)
CompileError: error: Command "g++ -m64 -g -shared c:\users\owner\appdata\local\temp\scipy-owner-tbcany\python27_intermediate\compiler_e3b0c44298fc1c149afbf4c8996fb924\Release\users\owner\appdata\local\temp\owner\python27_compiled\sc_cb1945ea063627b5855c13eafebb07042.o c:\users\owner\appdata\local\temp\scipy-owner-tbcany\python27_intermediate\compiler_e3b0c44298fc1c149afbf4c8996fb924\Release\python27\lib\scipy\weave\scxx\weave_imp.o -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lpython27 -lmsvcr90 -o c:\users\owner\appdata\local\temp\owner\python27_compiled\sc_cb1945ea063627b5855c13eafebb07042.pyd" failed with exit status 1
weave.test() 没有发现任何错误,但它只运行了 146 个测试,文档http://docs.scipy.org/doc/scipy/reference/tutorial/weave.html说它应该运行 180 个。
>>> weave.test()
Running unit tests for scipy.weave
NumPy version 1.9.1
NumPy is installed in C:\Python27\lib\site-packages\numpy
SciPy version 0.15.1
SciPy is installed in C:\Python27\lib\scipy
Python version 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)]
nose version 1.3.7
..................................S.SSS....SSSSSS.................................................................................................
----------------------------------------------------------------------
Ran 146 tests in 3.439s
OK (SKIP=10)
<nose.result.TextTestResult run=146 errors=0 failures=0>