Python does not find the Brownie file
Asked Answered
H

3

0

I'm following a tutorial on Solidity and Python (for reference https://www.youtube.com/watch?v=M576WGiDBdQ&t=5447s).

I'm at the stage where Python and Brownie have been installed and running through VSCode, but I am getting the below notification when asking for Brownie's version brownie --version INFO: Could not find files for the given pattern(s). Brownie v1.17.1 - Python development framework for Ethereum

When I try to run an extremely basic script on a file called deploy.py (def main(): print ("hello!") ), here is the result :

PS C:\Users\chret\Documents\demo\brownie_simple_storage> brownie run scripts/deploy.py
INFO: Could not find files for the given pattern(s).
Brownie v1.17.1 - Python development framework for Ethereum

BrownieSimpleStorageProject is the active project.

Launching 'ganache-cli.cmd --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\brownie\_cli\__main__.py", line 64, in main
  importlib.import_module(f"brownie._cli.{cmd}").main()
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\brownie\_cli\run.py", line 44, in main
  network.connect(CONFIG.argv["network"])
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\brownie\network\main.py", line 50, in connect
  rpc.launch(active["cmd"], **active["cmd_settings"])
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\brownie\network\rpc\__init__.py", line 75, in launch
  self.process = self.backend.launch(cmd, **kwargs)
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\brownie\network\rpc\ganache.py", line 73, in launch
  return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out)
File "C:\Users\chret\AppData\Roaming\Python\Python39\site-packages\psutil\__init__.py", line 1312, in __init__
  self.__subproc = subprocess.Popen(*args, **kwargs)
File "C:\Program, line line, in in
  self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program, line line, in in
  hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

I've tried uninstalling and reinstalling from Python to Brownie, changing the place where Brownie's files are, but I'm now stuck due to my very limited knowledge (full beginner).

UPDATE I've reinstalled Python and pipx and brownie once more, and now the message is slightly different, but still doesn't run the script of deploy.py. The script is :

def main():
    print("Hello!")

and the current error message is :

PS C:\Users\chret\Documents\demo\brownie_simple_storage> brownie run scripts.deploy.py

INFO: Could not find files for the given pattern(s).
Brownie v1.17.1 - Python development framework for Ethereum

BrownieSimpleStorageProject is the active project.

Launching 'ganache-cli.cmd --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\_cli\__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\_cli\run.py", line 44, in main
    network.connect(CONFIG.argv["network"])
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\main.py", line 50, in connect
    rpc.launch(active["cmd"], **active["cmd_settings"])
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\rpc\__init__.py", line 75, in launch
    self.process = self.backend.launch(cmd, **kwargs)
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\rpc\ganache.py", line 73, in launch
    return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out)
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\psutil\__init__.py", line 1312, in __init__
    self.__subproc = subprocess.Popen(*args, **kwargs)
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
PS C:\Users\chret\Documents\demo\brownie_simple_storage>

Image of the directory: screenshot of file location

Any help would be greatly appreciated :)

After trying all suggestions, I ended up making it work only by uninstalling and removing every single program and related files. Uninstalled Python, removed all the files related to Python from my computer, did the same for VSCode, removed all the npm packages, yarn, solc, everything related to the tutorial (I didn't have anything for coding before).

Then, reproduced all the steps until the original post issue, and everything worked fine... A bit frustrating not to know how the issue really got resolved, but it did.

Halliehallman answered 11/11, 2021 at 11:50 Comment(0)
D
1

Your deploy script is in the contracts folder/directory.

It needs to be in scripts directory of your project, your brownie_simple_storage/scripts folder.

Try moving it there, and running your script in that folder.

EDIT:

You may need to install nodejs and ganache-cli

Demure answered 15/11, 2021 at 13:30 Comment(7)
I've moved the deploy.py script to the brownie_simple_storage folder, and the error message is still the sameHalliehallman
ah sorry, please put deploy.py in your scripts folder.Demure
Same error message... One thing that is strange as well, is that when I type ` Python --version` I get the version printed out nicely, but when I do the same with Brownie, I get ` INFO: Could not find files for the given pattern(s). Brownie v1.17.1 - Python development framework for Ethereum`. could the problem be coming from Brownie's installation folder?Halliehallman
No, that's fine. Do you have the ganache-cli installed?Demure
I did, but when I checked, I receive this message : ganache-cli : The term 'ganache-cli' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ganache-cli --version + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (ganache-cli:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Installed it again through Yarn, same error message came backHalliehallman
I have tried the solution found on this post #69236878 but it still shows me the same error messageHalliehallman
How about this? ethereum.stackexchange.com/a/103490/57451Demure
T
1

I think since brownie is installed via pipx, you have to tell vs code for the path.

  • ctrl + shift + p

  • Python: select Interpreter

enter image description here

  • Find the path in os. this is in linux

      ~/.local/pipx/venvs/eth-brownie/bin/python
    

I am using Linux, so find the path in your system and add it there.

Thousandfold answered 31/12, 2021 at 8:42 Comment(0)
M
0

Well start by downloading ganache cli using :

npm install -g ganache-cli

then again try running script using:

brownie run scripts/deploy.py

Hope this will work..

Melanymelaphyre answered 28/6, 2023 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.