1

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)

Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359

3 Answers3

4

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
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
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.

ChrisC
  • 1,282
  • 9
  • 9
0

Let me give an answer that isn't outdated.

Why does it happen?

pygame is written in C, so it needs to be compiled before it can be installed. setup.py tries to compiled it using Visual Studio Build Tools, and if they're not installed on your PC, it fails.

How do I install pygame?

Pip provides pre-compiled versions of pygame so you don't have to compile them yourself. If you get the error, then it hasn't been compiled for your version of Python yet. Try downgrading Python.

E.g. I had to downgrade from 3.11 to 3.10.

More info: https://devblogs.microsoft.com/python/unable-to-find-vcvarsall-bat/

serg06
  • 2,027
  • 1
  • 18
  • 26