This chapter will take you through the basic steps of installing SCons so you can use it for your projects. Before that, however, this chapter will also describe the basic steps involved in installing Python on your system, in case that is necessary. Fortunately, both SCons and Python are easy to install on almost any system, and Python already comes installed on many systems.
Because SCons is written in the Python programming language,
you need to have a Python interpreter available on your system
to use SCons.
Before you try to install Python,
check to see if Python is already
available on your system by typing
python -V
(capital 'V')
or
python --version
at your system's command-line prompt.
For Linux/Unix/MacOS/BSD type systems this looks like:
$ python -V
Python 3.9.15
If you get a version like 2.7.x, you may need to try using the name python3 - current SCons no longer works with Python 2.
Note to Windows users: there are a number of different ways Python can be installed or invoked on Windows, it is beyond the scope of this guide to unravel all of them. Some have an additional program called the Python launcher (described, somewhat technically, in PEP 397): try using the command name py instead of python, if that is not available drop back to trying python
C:\>py -V
Python 3.9.15
If Python is not installed on your system,
or is not findable in the current search path,
you will see an error message
stating something like "command not found"
(on UNIX or Linux)
or "'python' is not recognized as an internal
or external command, operable progam or batch file"
(on Windows cmd).
In that case, you need to either install Python
or fix the search path
before you can install SCons.
The link for downloading Python installers (Windows and Mac) from the project's own website is: https://www.python.org/download. There are useful system-specific entries on setup and usage to be found at: https://docs.python.org/3/using
For Linux systems, Python is almost certainly available as a supported package, probably installed by default; this is often preferred over installing by other means as the system package will be built with carefully chosen optimizations, and will be kept up to date with bug fixes and security patches. In fact, the Python project itself does not build installers for Linux for this reason. Many such systems have separate packages for Python 2 and Python 3 - make sure the Python 3 package is installed, as the latest SCons requires it. Building from source may still be a useful option if you need a specific version that is not offered by the distribution you are using.
Recent versions of the Mac no longer come with Python pre-installed; older versions came with a rather out of date version (based on Python 2.7) which is insufficient to run current SCons. The python.org installer can be used on the Mac, but there are also other sources such as MacPorts and Homebrew. The Anaconda installation also comes with a bundled Python.
Windows has even more choices. The Python.org installer is
a traditional .exe
style;
the same software is also released as a Windows application through
the Microsoft Store. Several alternative builds also exist
such as Chocolatey and ActiveState, and, again,
a version of Python comes with Anaconda.
SCons will work with Python 3.6 or later. If you need to install Python and have a choice, we recommend using the most recent Python version available. Newer Python versions have significant improvements that help speed up the performance of SCons.