Recommended Free Tools
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
On Windows, compile CPython with the Visual Studio/MSBuild projects in the source tree’s PCbuild directory—not with Unix commands such as ./configure and make. Install the required Visual Studio C++ toolchain, obtain a CPython release source tree, run PCbuildbuild.bat, and launch the resulting executable from PCbuildamd64 for an x64 build.
What you are compiling
CPython is the reference Python implementation, written mainly in C. This procedure compiles its interpreter and Windows extension modules from source. It does not compile a Python script, create a virtual environment, install packages with pip, or build the Python Launcher.
The result is an in-place build inside the source tree rather than an automatic system-wide installation. A Release build normally produces python.exe; a Debug build produces python_d.exe. The tree also contains the CPython runtime DLL and .pyd extension modules.
“From scratch” has a practical qualification: the normal Windows build compiles CPython from source but retrieves or uses external dependencies for features such as SSL, SQLite, compression, and Tkinter. It is not a dependency-free build.
#1 Best Overall
This guide targets a current CPython branch on supported 64-bit Windows. Current CPython source defines Windows 10 as the minimum target for Python 3.13 and later, but older branches have different requirements. See the Windows compilation documentation and the repository’s PCbuild instructions.
The shortest successful build
After installing the prerequisites, use a native PowerShell or Command Prompt window—not WSL—to clone and build CPython:
git clone https://github.com/python/cpython.git
cd cpython
git checkout <release-tag>
PCbuildbuild.bat -c Release -p x64
PCbuildamd64python.exe -c "import sys; print(sys.executable); print(sys.version)"
Replace <release-tag> with the specific release you want. Building a tag is reproducible; building main follows active development and may change requirements or output behavior. You can also download a source archive from the official CPython repository or Python release page.
Install the Windows toolchain
Use Visual Studio Installer to install a supported Visual Studio edition or the corresponding Build Tools. Current CPython documentation requires Visual Studio 2017 or later, although the exact toolset depends on the CPython branch.
Confirm that the installation includes:
- Python development workload.
- Python native development component requested by CPython.
- Desktop development with C++ workload or equivalent C++ build tools.
- MSBuild.
- A Windows SDK.
- Compiler and host tools for your target architecture.
Component names can vary between Visual Studio releases. Microsoft’s current workload and component list is the authoritative reference. A full Visual Studio IDE is not essential for command-line compilation if the required Build Tools and MSBuild components are installed.
Install Git for Windows if you plan to clone the repository. Keep the checkout on a normal Windows filesystem. The CPython developer guide warns that cloning or manipulating the tree through a WSL-mounted path can prevent Visual Studio from locating files correctly.
An existing Python 3.10-or-later installation is useful for helper scripts. If one is unavailable, the current build process can obtain a suitable helper Python through NuGet. The first build may also need network access to retrieve external dependencies; do not assume a fixed build time or disk requirement because both vary by source revision and machine.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #2
Inspect the build script
From the repository root, run:
PCbuildbuild.bat -h
The checked-out source tree is authoritative because options change between branches. Current scripts include configurations such as Release, Debug, PGInstrument, and PGUpdate; platforms such as x64, Win32, ARM, and ARM64; and targets including Build, Rebuild, Clean, and CleanAll. They also expose reduced-build switches such as --no-ssl, --no-tkinter, and --no-ctypes.
Build a Release interpreter
For the normal 64-bit Windows build:
PCbuildbuild.bat -c Release -p x64
The no-argument form is also supported by the current process:
PCbuildbuild.bat
Explicitly specifying the configuration and platform is clearer because it documents your intended output. For x64, run the resulting interpreter with:
PCbuildamd64python.exe -c "import sys; print(sys.executable); print(sys.version)"
Checking sys.executable matters. Windows may have several Python installations, virtual environments, PATH entries, or install-manager shims. Use the explicit local path until you have confirmed that the new binary works.
Free tools Windows power users keep installed
One-click scans. No signup required.
Build a Debug interpreter
Debug builds add checks and assertions and are useful for CPython development or diagnosing native problems:
PCbuildbuild.bat -c Debug -p x64
PCbuildamd64python_d.exe -c "import sys; print(sys.executable); print(sys.version)"
Debug binaries use the _d suffix and are slower than Release builds. They are not the normal production configuration.
Choose an architecture
| Command | Typical output directory | Use |
|---|---|---|
PCbuildbuild.bat -p x64 |
PCbuildamd64 |
Default choice for most current 64-bit Windows systems |
PCbuildbuild.bat -p Win32 |
PCbuildwin32 |
32-bit compatibility testing |
PCbuildbuild.bat -p ARM64 |
Architecture-specific output | Native Windows on ARM builds |
PCbuildbuild.bat -p ARM |
Architecture-specific output | ARM target support where available |
The platform argument alone is not enough for ARM builds. Install the matching Visual Studio compiler, SDK, host tools, and target support. Do not confuse x64, ARM64, and Win32.
Test the compiled interpreter
Run the test suite after compilation:
PCbuildrt.bat -q
A successful compile does not prove that every extension module works. Results can vary with the configuration, architecture, Windows version, installed tools, network access, permissions, locale, and source revision. Tests may also include platform-specific or newly introduced cases.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesFor a basic feature check, run the modules most often affected by missing dependencies:
PCbuildamd64python.exe -c "import ssl; print(ssl.OPENSSL_VERSION)"
PCbuildamd64python.exe -c "import sqlite3; print(sqlite3.sqlite_version)"
PCbuildamd64python.exe -c "import tkinter; print(tkinter.TkVersion)"
Use python_d.exe instead when validating a Debug build.
What the build depends on
The current Windows build scripts normally retrieve matched external dependencies through CPython’s helper scripts. Exact versions are release-specific; do not randomly substitute library builds merely because their names match.
| Feature | Relevant dependency or consideration |
|---|---|
_ssl and parts of hashlib |
OpenSSL |
_sqlite3 |
SQLite |
_tkinter, IDLE, and turtle |
Tcl/Tk |
zlib and gzip |
Compression support |
compression.zstd |
zstd |
_ctypes |
libffi-related support |
ensurepip |
Bundled or build-time components from the checked-out tree |
Reduced builds are useful for isolating a failure but are not the preferred first build:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
PCbuildbuild.bat --no-ssl
PCbuildbuild.bat --no-tkinter
PCbuildbuild.bat --no-ctypes
For example, omitting SSL intentionally creates a Python without the normal _ssl extension. The PCbuild documentation also describes Tcl/Tk handling and the prepare_tcltk.bat helper.
Clean and rebuild
Use an incremental build for ordinary work:
PCbuildbuild.bat -t Build -p x64 -c Release
When generated files, compiler settings, or dependencies may be stale, rebuild:
PCbuildbuild.bat -t Rebuild -p x64 -c Release
For a less destructive cleanup:
PCbuildbuild.bat -t Clean -p x64 -c Release
For a deeply inconsistent tree:
PCbuildbuild.bat -t CleanAll -p x64 -c Release
CleanAll can require dependencies to be rebuilt or retrieved again. Keep Debug and Release, and x64 and Win32, conceptually separate; mixing outputs is a common source of misleading linker and module errors.
Use Visual Studio after the first command-line build
Once the script has completed successfully, open the solution:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →start PCbuildpcbuild.sln
In Visual Studio, select the same configuration and platform used by the script—for example, Debug and x64. Starting with build.bat is preferable because it retrieves dependencies and prepares generated files before the IDE loads the projects. Changing configuration or platform in Visual Studio first can leave stale or mismatched files.
Advanced configurations
Profile-guided optimization
CPython’s Windows scripts support PGO-related configurations and a --pgo workflow. Do not use PGInstrument or PGUpdate as ordinary first-build configurations. PGO is a multi-stage process involving an instrumented build and training workload. Build and test ordinary Release first, then evaluate PGO with a controlled benchmark rather than assuming it improves every workload.
Clang-cl
Advanced users can select Clang/LLVM through the Visual Studio/MSBuild integration:
PCbuildbuild.bat "/p:PlatformToolset=ClangCL"
Additional properties such as LLVMInstallDir and LLVMToolsVersion may be needed for a separately installed LLVM toolchain. MSVC is the least-surprising baseline; Clang-cl is useful for compiler testing and alternative diagnostics but introduces more toolchain variables.
Creating an installer
Compiling CPython is not the same as producing a Windows installer. Installer creation is documented separately under Toolsmsi in the CPython installer instructions.
Best Value
Troubleshooting
MSBuild cannot be found
Reopen a fresh terminal, then verify the Visual Studio installation. Add the C++ build tools, MSBuild, Windows SDK, and requested native-development components through Visual Studio Installer. The build script attempts to locate MSBuild and reports an error if it cannot. Avoid hard-coding a path copied from another Visual Studio installation.
Projects fail to load in Visual Studio
Build from a native Windows filesystem and terminal, not a WSL-mounted checkout. Then run a matching rebuild:
PCbuildbuild.bat -t Rebuild -c Debug -p x64
Reopen PCbuildpcbuild.sln and select the same configuration and platform. An incomplete checkout or missing dependency retrieval can cause the same symptom.
Dependency downloads fail
Check the dependency name and URL in the build log. Firewall, proxy, GitHub access, or an unavailable archive may be responsible. Retry on a network that permits the download and prefer an official release tag over an unstable branch. Do not substitute arbitrary OpenSSL, SQLite, or Tcl/Tk builds unless you understand their ABI and CPython’s project files. If you deliberately omit a dependency, use the matching --no-* option and document the missing feature.
import ssl fails
First prove which executable is running:
PCbuildamd64python.exe -c "import sys; print(sys.executable)"
PCbuildamd64python.exe -c "import ssl; print(ssl.OPENSSL_VERSION)"
Failure may mean SSL was omitted, OpenSSL retrieval or linking failed, or a different Python was launched. Repeat with python_d.exe for Debug.
tkinter is unavailable
Check whether --no-tkinter was used, whether Tcl/Tk dependencies were retrieved, and whether the executable’s architecture matches the dependencies:
PCbuildamd64python.exe -c "import tkinter; print(tkinter.TkVersion)"
The wrong Python runs
Do not rely on python or py until the local executable has been validated. Always start with the explicit output path:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11PCbuildamd64python.exe -c "import sys; print(sys.executable)"
Incremental builds produce linker or module errors
Clean the matching configuration and try again:
PCbuildbuild.bat -t Clean -c Debug -p x64
PCbuildbuild.bat -c Debug -p x64
If the problem remains, use CleanAll, then confirm that you have not mixed Debug with Release or x64 with Win32.
What this build does not guarantee
- It does not install Python globally or create a normal installer.
- It does not eliminate third-party dependencies.
- It does not guarantee that every test passes on every machine.
- It is not necessarily bit-for-bit identical to a Python.org binary; compiler, flags, dependencies, PGO training, and environment can differ.
- It does not make the resulting interpreter ABI-compatible with every other Python build.
For most readers, the reliable path is: install the current Visual Studio C++ toolchain, check out a release tag, build Release for x64, verify PCbuildamd64python.exe explicitly, and run the test suite. Use Debug, alternate architectures, Clang-cl, or PGO only when you have a specific development or compatibility reason.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

