full-blockchain-solidity-course-py
full-blockchain-solidity-course-py copied to clipboard
Lesson 4 /usr/bin/which: no solc
I am going through the tutorial (see below) and when I run it, I get the error:
(solidity) [hdouglas@localhost web3PySimpleStorage]$ python deploy.py which: no solc in (/home/hdouglas/.local/share/solana/install/active_release/bin:/home/hdouglas/.local/share/solana/install/active_release/bin:/home/hdouglas/.local/share/solana/install/active_release/bin:/home/hdouglas/.local/share/solana/install/active_release/bin:/home/hdouglas/.nvm/versions/node/v14.18.1/bin:/home/hdouglas/.local/share/solana/install/active_release/bin:/home/hdouglas/anaconda3/envs/solidity/bin:/home/hdouglas/anaconda3/condabin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/hdouglas/.local/bin:/home/hdouglas/bin:/home/hdouglas/.local/bin:/home/hdouglas/bin) 0
I used pip install py-solc-x I used npm install solc
I see the /.solcx directory in my home directory. I also see solc-v0.6.0 in the .solcx directory.
If I type in: PATH=/home/hdouglas/.solcx:$PATH /usr/bin/which solc-v0.6.0
it will find solc-v0.6.0 but if I type in PATH=/home/hdouglas/.solcx:$PATH /usr/bin/which solc
it won't find anything.
Typing the command whereis solc
also yields nothing.
The program seems to still run, but with this error appearing. Is there a way to fix it, or should I just live with it?
My code up to this point is as follows `from solcx import compile_standard, install_solc import json from web3 import Web3
with open("./SimpleStorage.sol", "r") as file: simple_storage_file = file.read() #print(simple_storage_file)
#compile Solidity
install_solc("0.6.0") compiled_sol = compile_standard( { "language": "Solidity", "sources": { "SimpleStorage.sol": { "content": simple_storage_file } }, "settings": { "outputSelection": { "" : { "": [ "abi", "metadata", "evm.bytecode", "evm.sourceMap" ] } } } }, solc_version = "0.6.0" )
#print(compiled_sol) with open("compiled_code.json", "w") as file: json.dump(compiled_sol, file)
#get bytecode bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"]["bytecode"]["object"]
#get abi abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]
#for connecting to ganache w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:7545")) chain_id = 5777 my_address = "0x64328fEcb27500fd6fd8d6d90a205f1940Ac933f" private_key = "0x6f30a6eec0f9f816161a2bdf1c7822630c900e4fd6904a21dff599dd5f5aca41"
#create the contract in python SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)
#get the latest transaction nonce = w3.eth.getTransactionCount(my_address) print(nonce)
#1 . Build a transaction #2. Sign a transaction #3 Send a transaction
transaction = SimpleStorage.constructor().buildTransaction({"gasPrice": w3.eth.gas_price, "chainID": chain_id, "from": my_address, "nonce": nonce}) `
I have a similar issue, although my code just doesn't find solcx or web3, I have installed all of the modules, I can see them on my npm ls and pip lists but yet they don't work. I get the error
Traceback (most recent call last):
File "deploy.py", line 2, in
Traceback (most recent call last):
File "deploy.py", line 5, in
zsh: command not found: solcx zsh: command not found: web3
I ended up solving the problem by installing solc via snapd. Unfortunately, it means I had to install solc and not solcx.
Here's where someone else solved the problem: https://ethereum.stackexchange.com/questions/104058/cant-compile-contracts-with-brownie-because-of-this-error-which-no-solc-in-pa
did you tryed to install it with the admin rights
I had the similar error but with this command "sudo snap install solc" it solved but I didn't use solc in my code, I just import solcx. thanks @claxtonh