Skip to content

Cannot find import file #57

Open
Open
@ayeteng

Description

  • py-solc Version: 3.1.0
  • solc Version: 0.4.24
  • Python Version: 3.7
  • OS: osx

What was wrong?

  • full output of the error you received

/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:
    <stdin>:2:1: Error: Source "interfaces/ISimpleStorage.sol" not found: File not found.

import './interfaces/ISimpleStorage.sol';
^---------------------------------------^

  • the code that caused the failure
    There is an import in the solidity contract that I try to import another contract. But the program cannot find it.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions