ethereum / py-solc

Python wrapper around the solc Solidity compiler.
MIT License
184 stars 232 forks source link

Cannot find import file #57

Open ayeteng opened 6 years ago

ayeteng commented 6 years ago

What was wrong?

/usr/local/bin/python3.7 /Users/sam/work/tutorial/test/web3_test.py Traceback (most recent call last): File "/Users/sam/work/tutorial/test/web3_test.py", line 80, in compiled_sol = compile_source(contract_source_code, allow_paths=PROJECT_ROOT) # Compiled source code File "/usr/local/lib/python3.7/site-packages/solc/main.py", line 108, in compile_source stdoutdata, stderrdata, command, proc = solc_wrapper(*compiler_kwargs) File "/usr/local/lib/python3.7/site-packages/solc/utils/string.py", line 85, in inner return force_obj_to_text(fn(args, **kwargs)) File "/usr/local/lib/python3.7/site-packages/solc/wrapper.py", line 169, in solc_wrapper stderr_data=stderrdata, solc.exceptions.SolcError: An error occurred during execution

command: solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc --allow-paths /Users/sam/work/tutorial return code: 1 stderr:

stdout:

:2:1: Error: Source "interfaces/ISimpleStorage.sol" not found: File not found. import './interfaces/ISimpleStorage.sol'; ^---------------------------------------^

in my python code:

contract_source_code = open('../contracts/storage/SimpleStorage.sol', 'r').read()
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
compiled_sol = compile_source(contract_source_code, allow_paths=PROJECT_ROOT)  # Compiled source code

in my SimpleStorage.sol:

pragma solidity ^0.4.24;
import './interfaces/ISimpleStorage.sol';

Tree: . ├── Migrations.sol ├── SimpleStorage.sol ├── storage │   ├── SimpleStorage.sol │   └── interfaces │    └── ISimpleStorage.sol ├── token │   ├── ERC20Token.sol │   └── interfaces │    └── IERC20Token.sol └── utility └── Utils.sol

Cute Animal Picture

cc

theGavinBrick commented 6 years ago

I just encountered the same error, looking into the pysolc source code it appears like it might not be an issue with pysolc at all, but rather an issue with solidity 0.4.24 -- https://github.com/ethereum/solidity/issues/2742 describes an almost identical problem that has not yet been fixed.

ayeteng commented 6 years ago

If I run it under terminal with command: console> solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc --allow-paths /Users/sam/work/tutorial ./SimpleStorage.sol It can output the correct result. I am not sure if the issue related with ethereum or py-solc.

ppLorins commented 5 years ago

@ayeteng I got the same issue with yours . Compiling the .sol file with solc in command line is okay, but went wrong if using solc-py . I don't think it is a solidity 0.4.24 issue .

whime commented 5 years ago

had anyone solve this problem? It has troubled me several days...