Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: [WinError 2] The system cannot find the file specified #46

Closed
sjtupingjian opened this issue Mar 26, 2018 · 5 comments

Comments

@sjtupingjian
Copy link

sjtupingjian commented Mar 26, 2018

  • py-solc Version: 2.1.0
  • solc Version: 0.4.17
  • Python Version: 3.6
  • OS: win

What was wrong?

I try to compile a contract like this:

import json
import web3
import sys

from solc import compile_standard,compile_source,compile_files, link_code
from web3.contract import ConciseContract

compile_standard({'language': 'Solidity','sources': 'MetaCoin.sol'})

Executing this function returns an error:

Traceback (most recent call last):
  File "C:/Users/com/PycharmProjects/test/testCompile.py", line 35, in <module>
    compiled_sol = compile_source(contract_source_code)
  File "C:\Users\com\PycharmProjects\test\venv\lib\site-packages\solc\main.py", line 106, in compile_source
    stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs)
  File "C:\Users\com\PycharmProjects\test\venv\lib\site-packages\solc\utils\string.py", line 85, in inner
    return force_obj_to_text(fn(*args, **kwargs))
  File "C:\Users\com\PycharmProjects\test\venv\lib\site-packages\solc\wrapper.py", line 155, in solc_wrapper
    stderr=subprocess.PIPE)
  File "D:\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "D:\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

How can I fix it?

Cute Animal Picture

put a cute animal picture here.
default

@dylanjw
Copy link

dylanjw commented Mar 26, 2018

Can you add some checks for the solc executable and the source file? e.g.:

import os
source_path = 'MetaCoin.sol'
if not os.path.exists(source_path):
    raise FileNotFoundError("File not found at path: {0}".format(os.path.realpath(source_path)) 
if not os.path.exists('solc'):
    raise FileNotFoundError("solc executable not found.  Is solc installed?")

@sjtupingjian
Copy link
Author

Thanks for reply!

It returns error:

Traceback (most recent call last):
  File "C:/Users/com/PycharmProjects/test/testCompile.py", line 17, in <module>
    raise FileNotFoundError("solc executable not found.  Is solc installed?")
FileNotFoundError: solc executable not found.  Is solc installed?

I am still confused because the solc compiler was installed and it does work in commandline:

C:\Users\com>solcjs --help
Usage: AppData\Roaming\npm\node_modules\solc\solcjs [options] [input_file...]

Options:
  --version         Show version number                                [boolean]

  --optimize        Enable bytecode optimizer.                         [boolean]

  --bin             Binary of the contracts in hex.                    [boolean]

  --abi             ABI of the contracts.                              [boolean]

  --standard-json   Turn on Standard JSON Input / Output mode.         [boolean]

  --output-dir, -o  Output directory for the contracts.                 [string]

  --help            Show help                                          [boolean]

@dylanjw
Copy link

dylanjw commented Mar 27, 2018

the solcjs package only gives the solc binary embedded in a js file behind js bindings. It wont work for py-solc, which requires the solc binary to be in the executable path.

Unfortunately the handy py-solc installer helper does not work on windows:

$ python -m solc.install v0.4.19

You can download a compiled binary from https://github.com/ethereum/solidity/releases. Then either place the binary in you executable path, or set the SOLC_BINARY environmental variable with the path of the solc executable.

@dylanjw
Copy link

dylanjw commented Mar 29, 2018

#48

@dylanjw dylanjw closed this as completed Mar 29, 2018
@ppLorins
Copy link

ppLorins commented Nov 15, 2018

Same issue. solc is available in the commond line , but throws exceptions by this snippet :

if not os.path.exists('solc'):
    raise FileNotFoundError("solc executable not found.  Is solc installed?")

Win7 solc:0.4.25+commit.59dbf8f1.Windows.msvc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants