Pygame installation on Windows - error: Unable to

2019-07-28 17:47发布

问题:

I have a Win7 64 bit dev machine. I've downloaded and installed Python 2.6.6 32bit. I've also downloaded pygame 1.9.1 for python 2.6 and tried to install it. I got:

C:\pygame-1.9.1release>setup.py install
....
running build_ext
building 'pygame._numericsurfarray' extension
error: Unable to find vcvarsall.bat

What should I do?
(I don't have any compiler or visual studio or anything installed, if it's relevant)

回答1:

On PyGame's download page - use the msi file which is a dedicated Windows installation instead of downloading the source and executing:

setup.py install


回答2:

I had a similar problem with a package (Traits) a couple of weeks ago - for me it was because the package was trying to compile extensions and I didn't have Visual Studio. What worked for me was to install MinGW and direct Python to use it as the compiler in the distutils.cfg config file under \Lib\distutils in your Python installation folder. Looks like this page can automate the whole process for you; if you'd prefer to do it manually here's the contents of my distutils.cfg:

[build]

compiler=mingw32

Rerun setup.py and you should be good to go.