Help With Brownie and Infura Environment Variables (Will send a $tip for the help)

Hello, I’m a novice to coding in general and I’m stuck with a problem while trying to run a script using Brownie in Studio Visual Code. I think my problem is with the environment variables in brownie(I’m probably doing something wrong in the brownie-config.yaml file) while trying to use the Kovan test network. I’ve used Infura to create a Project ID, and I have metamask for a private key. When I run “brownie run scripts/ --network kovan” I receive this error “raise ValueError(f"Unable to expand environment variable in host setting: ‘{uri}’”)
ValueError: Unable to expand environment variable in host setting: ‘$WEB3_INFURA_PROJECT_ID’’ Do you have any suggestions? Thank you. This may be a simple solution for someone, and I’ll send a tip to someone that’s willing to help guide me through a few steps. Thanks again.

Hey @Brian_Lee_Victory, and welcome to the Infura community! After doing some digging and carefully looking at your error messages, I don’t think this is a Brownie issue as much as a Python issue.

You may want to look into os.path.expandvars(path) on this page. This will alow you to expand the environment variables at whatever path you put into it, which would be the Kovan URL you have mentioned.

Let me know if that works! If not, we’ll keep digging! :slight_smile:

1 Like

Hi @Leiya_Kenney, thank you so much for the reply and info. I’ve been reading over that article as I try to gain an understanding of environment variables since I’m new to coding in general. At the moment I"m receiving this Attribute error from running a script in Brownie, so I’ll just have to keep digging:

$ brownie run scripts/ --network kovan
INFO: Could not find files for the given pattern(s).
Brownie v1.14.3 - Python development framework for Ethereum

NewFolderProject is the active project.
  File "c:\users\brian, line line, in in
    return_value, frame = run(
  File "c:\users\brian, line line, in in
    raise AttributeError(f"Module '{name}' has no method '{method_name}'")
AttributeError: Module 'Users.Brian Lee.Python39.brownie.New folder.scripts.deploy' has no method 'main```

So that INFO error at the top is telling you that python.exe is not in the path that you’re trying to run - I’d check into fixing that first! When in doubt, follow the error messages :slight_smile:

1 Like

Hi Brian,
Just came across this. It looks like your first issue can be solved with this:

And your 2nd issue can be solved by adding a function named main in your script.

Hope it helps.

1 Like

I am also getting similar issue. Are you able to resolve it? If yes then can you post the solution that you have found.