Practical overview
When it fits
Use Py Solc when a Python workflow needs to invoke solc for Solidity compilation, including source-string, file-based or standard JSON compilation.
Who it is for
- Python developers building tools or scripts for Solidity projects.
- Teams that want to include Solidity compilation in local Python development workflows.
Documented uses
- Compile Solidity source text from a Python program.
- Compile one or more Solidity files from a script.
- Submit standard JSON compilation input and handle the returned compiler output.
- Link compiled bytecode by replacing a library placeholder.
Requirements & limits
- The solc executable is a separate required dependency; set
SOLC_BINARYto specify its path. - The project supports and tests solc versions 0.4.2 and later, while noting other versions may work.
- The documented installer for specific older solc versions is experimental and subject to breaking changes.
- The repository metadata specifies an MIT license.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Py Solc for a Python project
Install the Python wrapper and prepare its separately installed Solidity compiler dependency.
Before you start
- Python package installer, pip
- The solc executable; the project documents supported and tested versions 0.4.2 and later
Steps
Install the wrapper with the command below.
pip install py-solcInstall the
solcexecutable separately, following the Solidity installation instructions linked by the project.If needed, point Py Solc to the compiler binary by setting the
SOLC_BINARYenvironment variable.
Expected outcome
The Python package is installed and configured to use a solc executable for compiler calls.
Guide limitations
- Compiler versions 0.4.2 and later are the versions the project says it supports and tests; other versions may work.
- The package's optional compiler installer is experimental and subject to breaking changes.
Compile Solidity through Python
Call the documented Py Solc compilation functions with Solidity source or standard JSON input.
Before you start
- Py Solc installed
- A solc executable available to Py Solc
Steps
Import
compile_sourceorcompile_filesfromsolcfor legacy combined JSON compilation, or importcompile_standardfor standard JSON compilation.Pass Solidity source text to
compile_source, file paths tocompile_files, or a standard JSON input object tocompile_standard.For file-based standard JSON input that uses source URLs, pass the documented
allow_pathsargument for the source directory.
Expected outcome
The Python call returns compiler output containing contract, source and error information, as shown in the project's examples.
Guide limitations
- The examples document compiler invocation and output, not deployment or on-chain execution.
- The compiler executable is a separate dependency.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 16 October 2026
- Original website title
- ethereum/py-solc · Official homepage title · retained in its source language

