I installed py-solc and solidity:

solc, the solidity compiler commandline interface Version: 0.4.16+commit.d7661dd9.Darwin.appleclang

and ran this code in python (with a contract source example):

from solc import compile_source, compile_files, link_code

    source = """
    pragma solidity ^0.4.2;
    contract Example {
        string s="Hello World!";
        function set_s(string new_s) {
            s = new_s;
        function get_s() returns (string) {
            return s;

compiled = compile_source(source)

and the compile_source() function returned this error:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    compile_source("pragma solidity ^0.4.0;\n contract Foo {}", output_values=["bin", 'abi'])
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/solc/main.py", line 106, in compile_source
    stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/solc/utils/string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/solc/wrapper.py", line 155, in solc_wrapper
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'solc'

how is it possible to fix this issue and compile using py-solc?

4 Answers 4


The problem is solc is not installed on your pc. get it installed through

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

or you can go here


I also encountered this. For me it happened as a result of switching the python environment. Anyway, this can be solved by installing py-solc, or better solc-select.

pip3 install solc-select

Slyther repo issue.


There is also an experimental feature to ask py-solc to install solc for you:

Any of the following versions of solc can be installed using py-solc on the listed platforms.

  • v0.4.1 (linux)
  • v0.4.2 (linux)
  • v0.4.6 (linux)
  • v0.4.7 (linux)
  • v0.4.8 (linux/osx)
  • v0.4.9 (linux)
  • v0.4.11 (linux/osx)
  • v0.4.12 (linux/osx)
  • v0.4.13 (linux/osx)
  • v0.4.14 (linux/osx)
  • v0.4.15 (linux/osx)
  • v0.4.16 (linux/osx)
  • v0.4.17 (linux/osx)

Installation can be done via the command line:

$ python -m solc.install v0.4.17

I am on LinuxMint using Python3.6, you can run:

$ sudo pip install py-solc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.