Has anybody successful run cython on VS2010 - I get "error: Unable to find vcvarsall.bat"?

570 views
Skip to first unread message

Q&A

unread,
Oct 26, 2011, 4:58:28 PM10/26/11
to cython-users
cython on VS2008 was so good I also wanted to try it on VS2010 and
since I couldn't find anything definitively saying not supported, I
went ahead and tried it ....however, I got this error when trying to
cythonize:

error: Unable to find vcvarsall.bat

This is the setup.py with option --compiler=msvc and Python 2.7.2 and
Cython 0.15.1:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
name = 'RpcClient',
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("RpcClient",
["RpcClient.pyx"],
language="c++",
include_dirs=["../rpcHeaders"],
library_dirs=["../Debug", "../rpcLibs"],
libraries=["RpcClient", "rpcLib"],
define_macros=[('WIN32', None)]
)
]
)


刘振海

unread,
Oct 27, 2011, 12:29:12 AM10/27/11
to cython...@googlegroups.com
Hi,
When I try to use cython under msvc,I use the command line.
cython file.pyx
cl /I path_to_python_include file.c /dll /link /libpath:path_to_python_libs /out:file.pyd

Hope it will help!

Regards,
Liu Zhenhai 

2011/10/27 Q&A <qanap...@gmail.com>

刘振海

unread,
Oct 27, 2011, 12:32:19 AM10/27/11
to cython...@googlegroups.com

Hi,
Sorry,I just made a mistake.
the command line should be like this.
cython file.pyx
cl /I path_to_python_include file.c /link /dll /libpath:path_to_python_libs /out:file.pyd

Regards,
Liu Zhenhai

2011/10/27 刘振海 <1989...@gmail.com>

Q&A

unread,
Oct 27, 2011, 3:30:57 PM10/27/11
to cython-users
Yes, this is a great tip ... many thanks!

I had to setup the path correctly and add a few more command line
options but hand crafting from the command line appears to work well;
so to summarize it's a three step process with everything explicitly
stated via path or cmd line options:

(1) Append to the system "Path" variable with two new paths; one for
the VS2010 executables and one for it's dependent libraries e.g. on XP
via the "System" properties from the Control Panel:

C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

(2) From your Python sandbox or dev area cmd line, cythonize the pyx
into a cpp file:

cython --cplus RpcClient.pyx

(3) Compile and link the pyd file being very explicit about all the
options e.g. includes, paths and libs:

cl.exe /TpRpcClient.cpp /DWIN32 /I C:\Python27\include /I "C:\Program
Files\Microsoft Visual Studio 10.0\VC\include" /I "C:\Program Files
\Microsoft SDKs\Windows\v7.0A\Include" /I ../rpcHeaders/showIncludes /
link /dll /libpath:C:\Python27\libs /libpath:"C:\Program Files
\Microsoft Visual Studio 10.0\VC\lib" /libpath:"C:\Program Files
\Microsoft SDKs\Windows\v7.0A\Lib" ..\rpcLibs\rpcLib.lib ..\Release
\RpcClient.lib /verbose:lib /out:RpcClient.pyd

I'll continue testing and update if I find any further issues.

On Oct 26, 9:32 pm, 刘振海 <1989l...@gmail.com> wrote:
> Hi,
> Sorry,I just made a mistake.
> the command line should be like this.
> cython file.pyx
> cl /I path_to_python_include file.c /link /dll /libpath:path_to_python_libs
> /out:file.pyd
>
> Regards,
> Liu Zhenhai
>
> 2011/10/27 刘振海 <1989l...@gmail.com>
>
>
>
>
>
>
>
> > Hi,
> > When I try to use cython under msvc,I use the command line.
> > cython file.pyx
> > cl /I path_to_python_include file.c /dll /link /libpath:path_to_python_libs
> > /out:file.pyd
>
> > Hope it will help!
>
> > Regards,
> > Liu Zhenhai
>
> > 2011/10/27 Q&A <qanaple...@gmail.com>

刘振海

unread,
Oct 28, 2011, 12:31:27 AM10/28/11
to cython...@googlegroups.com

Hi,
I use the Visual Studio Command Prompt,So I didn't need to set the path and the include path issue.
It's convenient.
or use the follow command to set the environment for msvc

%comspec% /k ""c:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

Regards,
Liu Zhenhai

在 2011年10月28日 上午3:30,Q&A <qanap...@gmail.com>写道:
Yes, this is a great tip ... many thanks!

I had to setup the path correctly and add a few more command line
options but hand crafting from the command line appears to work well;
so to summarize it's a three step process with everything explicitlyvi
Reply all
Reply to author
Forward
0 new messages