[Ethereum] having a problem with solc-x version “solc 0.6.0 has not been installed”


I m trying to print out the variable (compiled_sol) as you will see in the code below of the python file named deploy.py so I can deploy my smart contract, but I keep running at this error

*****INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
  File "C:\Users\houde\Desktop\Blockchain\solidity_projects\web3_py_simple_storage\deploy.py", line 8, in <module> 
    compiled_sol = compile_standard(
  File "C:\Users\houde\AppData\Roaming\Python\Python39\site-packages\solcx\main.py", line 368, in compile_standard 
    solc_binary = get_executable(solc_version)
  File "C:\Users\houde\AppData\Roaming\Python\Python39\site-packages\solcx\install.py", line 194, in get_executable
    raise SolcNotInstalled(
solcx.exceptions.SolcNotInstalled: solc 0.6.0 has not been installed. Use solcx.install_solc('0.6.0') to install. ******

I did install the solc-x via this command pip install py-solc-x so I can compile the contracts but I don't know how to upgrade the version or what to do in this case, I will leave the code for you guys down below, and thank you a lot.

from solcx import compile_standard

with open("SimpleStorage.sol", "r") as file:
    simple_storage_file = file.read()

compiled_sol = compile_standard(
        "language": "solidity",
        "sources": {"simpleStorage.sol": {"content": simple_storage_file}},
        "settings": {
            "outputSelection": {
                "*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}


note:"the solc version 0.6.0 I m using it for the contract"

Best Answer

I'm working through this same course check this out and it will show you how to fix this error here: https://github.com/smartcontractkit/full-blockchain-solidity-course-py/blob/main/chronological-issues-from-video.md

You just need to do the following: On the line that says

from solcx import compile_standard

We need to change it to this line:

from solcx import compile_standard, install_solc

And then, we need to add a line right before we run the compile_standard code:


Alternatively, you can install Solc first before installing solcx and it will give you the old version of solidity compiler included. so all you have to do is import from solcx.

Also I noticed in your settings array here:

"*": {"*": {"abi", "metadata", "evm.bytecode", "evm.sourceMap"}}

you used curly braces instead of square brackets so you will need to fix that before you try to compile. It needs to look like this

"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
Related Topic