I am using python package py-solc-x for compiling the smart contract.


Gives path where my test contract exits. 'D:\\new.sol'

Then i use compile_files to compile the contract compile_files([os.path.abspath("D:/new.sol")]) , it gives KeyError.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Muvi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\solcx\main.py", line 137, in compile_files
    contracts = _parse_compiler_output(stdoutdata)
  File "C:\Users\Muvi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\solcx\main.py", line 73, in _parse_compiler_output
    data['ast'] = sources[source.split(':')[0]]['AST']
KeyError: 'D'

How can i solve this problem?


Looks like you've found a bug in py-solc-x.

As far as I can tell, the issue is specific to Windows paths that are given absolutely. I was able to compile successfully by using a path that did not include a drive letter.

I am the maintainer of py-solc-x, I will push a new version with a fix as soon as possible. In the short term try running the script from the same folder as new.sol and compile with solcx.compile_files(['new.sol']).

  • omg.. Thanks a lot sir.. I'm very pleased that i am able to contribute something. ☺ – Chidananda Nayak Jul 12 '19 at 8:53
  • 1
    I've just pushed a new version to pypi (v0.4.1) - this issue should now be fixed. – iamdefinitelyahuman Jul 14 '19 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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