Dogmatixed
Dogmatixed

Reputation: 794

Why am I getting the error "scons: *** no platform named 'win32'"?

I was trying to compile some C++ source that uses scons as its build system. On my 64 bit windows machine with python 3.2.X (64 bit) and what I thought was python 2.7.X (32 bit) I would get the following error when trying to run scons:

scons: *** no platform named 'win32'

I was fairly certain that my 2.7 installation was 32 bit, because in the past I'd tried using scons with a 64 bit system and it had outright refused to function. I spent an hour or so playing with it, tried repairing the install, poking around on google/SO, etc. but couldn't find a solution. Finally I uninstalled python 2.7 using both a 32 and a 64 bit installer (I guess I must've had both installed in the same location?), uninstalled scons, deleted the remaining python27 folder and reinstalled 32 bit python and scons.

Now scons works!

Since I hadn't found a solution on SO, I thought I should post mine, but I'd also like to know what causes this error?

What causes the scons error "no platform named 'win32'"?

Upvotes: 1

Views: 1361

Answers (1)

daramarak
daramarak

Reputation: 6155

I have actually had this problem myself. This is caused by the scons.bat using the wrong python library. Somehow the installation gets screwed up and when you run things in 2.7 it tries using the libraries from python 3. I solved this quite simply by editing the scons.bat script, and setting python path and python home in the script.

The changes are shown here.

Set PYTHONHOME=C:\Python27\
Set PYTHONPATH=C:\Python27\Lib\;C:\MinGW\bin;C:\Python27\Lib\site-packages
Set PATH=%PYTHONHOME%;%PYTHONPATH%;%PATH%

...
more stuff here
...
:WinNT
setlocal
@REM ensure the script will be executed with the Python it was installed for
set path=%~dp0;%~dp0..;%path%
c:\Python27\python -c "from os.path import join; import sys; sys.path = [ join  (sys.prefix, 'Lib', 'site-packages', 'scons-2.0.1'), join(sys.prefix, 'Lib', 'site-    packages', 'scons'), join(sys.prefix, 'scons-2.0.1'), join(sys.prefix, 'scons')] +   sys.path; import SCons.Script; SCons.Script.main()" %*
endlocal & set SCONS_ERRORLEVEL=%ERRORLEVEL%

After this it works fine as long as I specify this scons.bat script for running scons.

Upvotes: 4

Related Questions