full-blockchain-solidity-course-py
full-blockchain-solidity-course-py copied to clipboard
Lesson 4 - Error using solcx - No module named solcx
Hey, Even after applying the fix that you folks have suggested, the error remains the same
As mentioned earlier I have changed the 1st line to - from solcx import compile_standard, install_solc
and also added - install_solc("0.6.0")
Using pip install py-solc-x to install solcx
in the terminal window
What am I missing over here?
Thanks for our help
you don't need to do it using "pip install", just write the code "install_solc("0.6.0")" in the deploy.py file before the line compiled_sol = compile_standard()
also make sure your import install_solc in the first line
Hey, thanks for replying, Yes I have done that. Here is my code snippet
from solcx import compile_standard, install_solc
with open("./simplestorage.sol", "r") as file:
simple_storage_file = file.read()
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.bytecode.sourceMap"]
}
}
},
},
solc_version="0.6.0",
)
print(compiled_sol)
And in the terminal window
Before running this code - pip install py-solc-x
After that Python deploy.py
I am not able to debug what am I missing.
Thanks for your help
Hello @anuragpagaria on your vscode bottom left corner, you will have the python interpreter you are using, be sure to select the one on where you have installed py-solc-x
@anuragpagaria : I had the same problem as you and found that using the command python3 deploy.py
fixed my problem.
Does @gaussiao solution work for you @anuragpagaria ?
Most likely @cromewar is correct. Please have a look on how VSC is helping with virtual python environments
https://code.visualstudio.com/docs/python/environments
First you should create a virtual env in your project directory with
on Mac python3 -m venv .venv
on Windows python -m venv .venv
VSC will ask you to use this venv for your workspace, choose "yes" (important!)
Close the terminal in VSC and open a new one, now you should see (.venv) in every new line on your terminal.
Check if solcx is already installed here with
pip freeze
if its not in the list (expected) than install it with
pip install py-solc-x
This way you will have a nice and clean python environment everytime you work in this workspace and installations or worse "uninstallation" in the global python environment won't mess with your project.
You are awesome @n4n0b1t3
for me it was changing the two lines others had mentioned, but I also had to use "python3 deploy.py" instead of the command in the video.
I added
install_solc("0.6.0")
and then used "python3 deploy.yp" in the terminal and it worked! thanks all