<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/551" rel="nofollow">http://projects.scipy.org/scipy/ticket/551</a> on 2007-12-03 by trac user odonnems, assigned to unknown.</em></p>
<h6 dir="auto"></h6>
<p dir="auto">Introduction to my problem</p>
<h6 dir="auto"></h6>
<p dir="auto">I am trying to use scipy.weave.inline. I appear to get the same error no matter what compiler I try.</p>
<p dir="auto">Please note that I am attaching a python script with examples of weave.inline that I have been attempting to implement. This is messy and there are a lot of commented lines but will be a start to demonstrate what I am testing. Hopefully this will help someone.</p>
<p dir="auto">I have also tried to separate out the information below so it will read as easily as possible for any onlookers. Look at all section titles before digging too deep because they may not be in any intuitive order for those that are actual programmers.</p>
<p dir="auto">Thanks for any insight. It was suggested from the scipy list that I post these here.</p>
<p dir="auto">Also note, that there was an error in numpy for me. I had to comment several lines out before I got the weave error. This is included below as well.</p>
<p dir="auto">Also, all of this is new so I appologize for not providing all the necessary information. And when I say new, I know python only a little and I have never compiled source files. I have a lot of scripting and VB background however.</p>
<p dir="auto">Thank you,<br>
Michael</p>
<h6 dir="auto"></h6>
<p dir="auto">Installed software and OS:</p>
<h6 dir="auto"></h6>
<p dir="auto">scipy-0.6.0.win32-py2.4.exe<br>
wxPython2.8-win32-unicode-2.8.6.1-py24.exe<br>
pywin32-210.win32-py2.4.exe<br>
python-2.4.4.msi<br>
numpy-1.0.4.win32-py2.4.exe</p>
<p dir="auto">OS: Microsoft Windows XP Professional SP2</p>
<p dir="auto">Platform: win32 nt</p>
<p dir="auto">Python Version:<br>
2.4.4 (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1587293" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/71" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/71/hovercard" href="https://github.com/scipy/scipy/pull/71">#71</a>, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]</p>
<p dir="auto">Processor:<br>
Intel(R) Pentium(R) M processor 2.13GHz<br>
x86 Family 6 Model 13 Stepping 8</p>
<p dir="auto">I have also tried the most recent enthought binaries and I had the same problem.</p>
<p dir="auto">Compilers:<br>
MinGw<br>
Cygwin<br>
SDK 2003 toolkit<br>
SDK 2005<br>
(I followed the directions which I could find online with regard to setting up environment paths and modifications to the msvccompiler.py.</p>
<h6 dir="auto"></h6>
<p dir="auto">Error message:</p>
<h6 dir="auto"></h6>
<p dir="auto">From what I can tell the error seems to occur when compiling. the s,o =exec_command(cmd) does not write out to the two output files containing the s, o information. Looking at the files, I do not get the object file. Depending on the compiler this may be the .obj or .o file. The .cpp or c++ source file is created. I do not know if the compiler creates the cpp file or a library acts as an interpreter that writes the python to c++ which can then be converted to the object file. Or maybe it is something completely different.</p>
<p dir="auto">Here is the error using mingw:</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">&lt;weave: compiling&gt;<br>
running build_ext<br>
running build_src<br>
building extension "sc_552cccf5dbf4f6eadd273cdcbd5860521" sources<br>
customize Mingw32CCompiler<br>
customize Mingw32CCompiler using build_ext<br>
customize Mingw32CCompiler<br>
customize Mingw32CCompiler using build_ext<br>
building 'sc_552cccf5dbf4f6eadd273cdcbd5860521' extension<br>
compiling C++ sources<br>
C compiler: g++ -mno-cygwin -O2 -Wall</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">compile options: '-IC:\Python24\lib\site-packages\scipy\weave -IC:\Python24\lib\site-packages\scipy\weave\scxx -IC:\Python24\lib\site-packages\numpy\core\include -IC:\Python24\include -IC:\Python24\PC -c'<br>
g++ -mno-cygwin -O2 -Wall -IC:\Python24\lib\site-packages\scipy\weave -IC:\Python24\lib\site-packages\scipy\weave\scxx -IC:\Python24\lib\site-packages\numpy\core\include -IC:\Python24\include -IC:\Python24\PC -c C:\Python24\lib\site-packages\scipy\weave\scxx\weave_imp.cpp -o c:\temp\Michael\python24_intermediate\compiler_12e837eb1ea3ab5199fbcc0e83015e3f\Release\python24\lib\site-packages\scipy\weave\scxx\weave_imp.o<br>
Traceback (most recent call last):<br>
File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript<br>
exec codeObject in <strong>main</strong>.<strong>dict</strong><br>
File "C:\Documents and Settings\Michael\Application Data\ESRI\ArcToolbox\scripts\test_weave.py", line 341, in ?<br>
main()<br>
File "C:\Documents and Settings\Michael\Application Data\ESRI\ArcToolbox\scripts\test_weave.py", line 224, in main<br>
weave.inline('printf("%d\n",a);',['a'], verbose=2, type_converters=converters.blitz)  #, compiler = 'msvc', verbpse=2, type_converters=converters.blitz, auto_downcast=0) #'msvc' or 'gcc' or 'mingw32'<br>
File "C:\Python24\Lib\site-packages\scipy\weave\inline_tools.py", line 338, in inline<br>
auto_downcast = auto_downcast,<br>
File "C:\Python24\Lib\site-packages\scipy\weave\inline_tools.py", line 447, in compile_function<br>
verbose=verbose, **kw)<br>
File "C:\Python24\Lib\site-packages\scipy\weave\ext_tools.py", line 365, in compile<br>
verbose = verbose, **kw)<br>
File "C:\Python24\Lib\site-packages\scipy\weave\build_tools.py", line 269, in build_extension<br>
setup(name = module_name, ext_modules = [ext],verbose=verb)<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\core.py", line 176, in setup<br>
return old_setup(**new_attr)<br>
File "C:\Python24\Lib\distutils\core.py", line 149, in setup<br>
dist.run_commands()<br>
File "C:\Python24\Lib\distutils\dist.py", line 946, in run_commands<br>
self.run_command(cmd)<br>
File "C:\Python24\Lib\distutils\dist.py", line 966, in run_command<br>
cmd_obj.run()<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", line 217, in run<br>
self.build_extensions()<br>
File "C:\Python24\Lib\distutils\command\build_ext.py", line 405, in build_extensions<br>
self.build_extension(ext)<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", line 320, in build_extension<br>
extra_postargs=extra_args,<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\ccompiler.py", line 117, in CCompiler_compile<br>
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)<br>
File "C:\Python24\Lib\distutils\cygwinccompiler.py", line 149, in _compile<br>
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\ccompiler.py", line 34, in CCompiler_spawn<br>
s,o = exec_command(cmd)<br>
File "C:\Python24\lib\site-packages\numpy\distutils\exec_command.py", line 246, in exec_command<br>
exec_command_dir = exec_dir,<br>
File "C:\Python24\lib\site-packages\numpy\distutils\exec_command.py", line 346, in _exec_command_python<br>
status = int(f.read())<br>
ValueError: invalid literal for int():</p>
<p dir="auto">Error using sdk 2003 toolkit:</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">&lt;weave: compiling&gt;<br>
No module named msvccompiler in numpy.distutils; trying from distutils<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e<br>
running build_ext<br>
running build_src<br>
building extension "sc_552cccf5dbf4f6eadd273cdcbd5860522" sources<br>
No module named msvccompiler in numpy.distutils; trying from distutils<br>
customize MSVCCompiler<br>
customize MSVCCompiler using build_ext<br>
No module named msvccompiler in numpy.distutils; trying from distutils<br>
customize MSVCCompiler<br>
Missing compiler_cxx fix for MSVCCompiler<br>
customize MSVCCompiler using build_ext<br>
building 'sc_552cccf5dbf4f6eadd273cdcbd5860522' extension<br>
compiling C sources<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\temp<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\temp\Michael<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\temp\Michael\python24_compiled<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24\lib<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24\lib\site-packages<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24\lib\site-packages\scipy<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24\lib\site-packages\scipy\weave<br>
creating c:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\Python24\lib\site-packages\scipy\weave\scxx<br>
cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -IC:\Python24\lib\site-packages\scipy\weave -IC:\Python24\lib\site-packages\scipy\weave\scxx -IC:\Python24\lib\site-packages\numpy\core\include -IC:\Python24\include -IC:\Python24\PC /Tpc:\temp\Michael\python24_compiled\sc_552cccf5dbf4f6eadd273cdcbd5860522.cpp /Foc:\temp\Michael\python24_intermediate\compiler_d41d8cd98f00b204e9800998ecf8427e\Release\temp\Michael\python24_compiled\sc_552cccf5dbf4f6eadd273cdcbd5860522.obj /Zm1000<br>
Traceback (most recent call last):<br>
File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript<br>
exec codeObject in <strong>main</strong>.<strong>dict</strong><br>
File "C:\Documents and Settings\Michael\Application Data\ESRI\ArcToolbox\scripts\test_weave.py", line 341, in ?<br>
main()<br>
File "C:\Documents and Settings\Michael\Application Data\ESRI\ArcToolbox\scripts\test_weave.py", line 224, in main<br>
weave.inline('printf("%d\n",a);',['a'], verbose=2, type_converters=converters.blitz)  #, compiler = 'msvc', verbpse=2, type_converters=converters.blitz, auto_downcast=0) #'msvc' or 'gcc' or 'mingw32'<br>
File "C:\Python24\Lib\site-packages\scipy\weave\inline_tools.py", line 338, in inline<br>
auto_downcast = auto_downcast,<br>
File "C:\Python24\Lib\site-packages\scipy\weave\inline_tools.py", line 447, in compile_function<br>
verbose=verbose, **kw)<br>
File "C:\Python24\Lib\site-packages\scipy\weave\ext_tools.py", line 365, in compile<br>
verbose = verbose, **kw)<br>
File "C:\Python24\Lib\site-packages\scipy\weave\build_tools.py", line 269, in build_extension<br>
setup(name = module_name, ext_modules = [ext],verbose=verb)<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\core.py", line 176, in setup<br>
return old_setup(**new_attr)<br>
File "C:\Python24\Lib\distutils\core.py", line 149, in setup<br>
dist.run_commands()<br>
File "C:\Python24\Lib\distutils\dist.py", line 946, in run_commands<br>
self.run_command(cmd)<br>
File "C:\Python24\Lib\distutils\dist.py", line 966, in run_command<br>
cmd_obj.run()<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", line 217, in run<br>
self.build_extensions()<br>
File "C:\Python24\Lib\distutils\command\build_ext.py", line 405, in build_extensions<br>
self.build_extension(ext)<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", line 310, in build_extension<br>
extra_postargs=extra_args,<br>
File "C:\Python24\lib\distutils\msvccompiler.py", line 398, in compile<br>
self.spawn ([self.cc] + compile_opts + pp_opts +<br>
File "C:\Python24\Lib\site-packages\numpy\distutils\ccompiler.py", line 34, in CCompiler_spawn<br>
s,o = exec_command(cmd)<br>
File "C:\Python24\lib\site-packages\numpy\distutils\exec_command.py", line 246, in exec_command<br>
exec_command_dir = exec_dir,<br>
File "C:\Python24\lib\site-packages\numpy\distutils\exec_command.py", line 346, in _exec_command_python<br>
status = int(f.read())<br>
ValueError: invalid literal for int():</p>
</blockquote>
</blockquote>
</blockquote>
<h6 dir="auto"></h6>
<p dir="auto">Code used for weave inline:</p>
<h6 dir="auto"></h6>
<p dir="auto">Please not that when I try any of these variations, I get the same error but I am trying to provide as much information as possible.</p>
<h2 dir="auto">Example one</h2>
<p dir="auto">a = 1<br>
weave.inline('printf("%d\n",a);',['a'], verbose=2,type_converters=converters.blitz)</p>
<p dir="auto">For additional examples see attachment.</p>
<h6 dir="auto"></h6>
<p dir="auto">Error in Numpy:</p>
<h6 dir="auto"></h6>
<p dir="auto">Make the following changes to:<br>
C:\Python24\Lib\site-packages\numpy\distutils\exec_command.py in order to get weave to work.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'''
if os.name in ['nt','dos']:
    fdir,fn = os.path.split(pythonexe)
    fn = fn.upper().replace('PYTHONW','PYTHON')
    pythonexe = os.path.join(fdir,fn)
    assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
'''"><pre class="notranslate"><code class="notranslate">'''
if os.name in ['nt','dos']:
    fdir,fn = os.path.split(pythonexe)
    fn = fn.upper().replace('PYTHONW','PYTHON')
    pythonexe = os.path.join(fdir,fn)
    assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
'''
</code></pre></div>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1505" rel="nofollow">http://projects.scipy.org/scipy/ticket/1505</a> on 2011-08-31 by trac user kp, assigned to unknown.</em></p>
<p dir="auto">import scipy.special fails as DLL _cephes can't be loaded.</p>
<p dir="auto">I'm using following build<br>
Python 2.7 (64 bit)<br>
numpy-MKL-1.6.1 (64 bit)<br>
scipy-0.9.0 (64 bit)<br>
(from Christoph Gohlke Unoffical Python Extensions )</p>