Python does not find the Brownie file - python

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:
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.

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

I think since brownie is installed via pipx, you have to tell vs code for the path.
ctrl + shift + p
Python: select Interpreter
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.

Related

Subprocess access denied error when running nmap as System User

I'm trying to run a python script when the system boots on a Windows 10 workstation. My python script runs fine when I kick it off in a different directory as a user with administrative privileges but when I run it from a bat file in the C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup folder on system boot I receive the following error in my logs.
2018-11-13 04:43:58,913 - VP - Level 55 - nmap args: ['"C:\\Program Files (x86)\\Nmap\\nmap.exe"', '-oX', 'C:\\\\nmap\\NmapResults\\scan-192.168.1.5-20181113044358.xml', '-sS', '-n', '-p-', '--allports', '--scan-delay', '1ms', '-sU', '-sV', '--version-all', '192.168.1.5']
Traceback (most recent call last):
File "secnmap\nmap_scanner.py", line 596, in <module>
exit_code = main()
File "secnmap\nmap_scanner.py", line 248, in main
run_nmap(args, scan_options, host_data_list, use_service_name_check)
File "secnmap\nmap_scanner.py", line 268, in run_nmap
nmap_proc = subprocess.Popen(nmap_cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 5] Access is denied
Here is the content of the .bat file.
cd C:\\nmap_startup
python nmap_startup.py
I have tried using the full nmap.exe path as shown in the code snippet as well as plain old nmap. I get the access denied error either way. I didn't see much in subprocess.py that would lead me to believe this to be an error with the python code either so I am leaning on it being an issue with System user running the script. If someone thinks otherwise or has any ideas, I'd love to hear them. Thanks
EDIT: I chose to run from a bat file because my python version is 32bit and I was having issues running from the C:\windows\system32 directory
It turns out that the path to nmap, C:\Program Files (x86)\Nmap, was not included in the system environment variables. When the script ran as a System user, it did not recognize the location of nmap

IOError: [Errno 0] Error while writing to output of Powershell in VSCode

This is the error I get in VSCode when running docker-compose.
PS D:\Work\Imho\Api> docker-compose -f docker-compose.yml up
Creating network "api_default" with the default driver
Pulling ignite (apacheignite/ignite:latest)...
latest: Pulling from apacheignite/ignite
5040bd298390: Pulling fs layer
fce5728aad85: Pulling fs layer
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\main.py", line 68, in main
File "compose\cli\main.py", line 118, in perform_command
File "compose\cli\main.py", line 926, in up
File "compose\project.py", line 401, in up
File "compose\service.py", line 305, in ensure_image_exists
File "compose\service.py", line 1001, in pull
File "compose\progress_stream.py", line 37, in stream_output
File "codecs.py", line 370, in write
File "site-packages\colorama\ansitowin32.py", line 40, in write
File "site-packages\colorama\ansitowin32.py", line 141, in write
File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
IOError: [Errno 0] Error
Failed to execute script docker-compose
docker-compose.yml:
version: '3'
services:
ignite:
image: apacheignite/ignite
This error only happens on one of my 3 machines, so I have no idea what causes it. Resetting to factory defaults or reinstalling docker and vscode doesn't help. Without docker compose the image is pulling and then working fine. All the machines are on windows 10 and latest stable docker installed.
Here is the issue I opened on github. It appeared that this behavior only occurs in VSCode powershell console, but not in regular powershell console. The solution with changing encoding suggested there didn't help.
Solution: Update to 1803 on Windows 10. If you can't update, use external command prompt.
The same thing happens to me with Python scripts. Apparently, this is a Windows Update issue:
https://github.com/Microsoft/vscode/issues/36630#issuecomment-359969098
Edit: My workaround due to my company restricting updates is to use external terminal in VS Code

Error using PyInstaller

I'm trying to use PyInstaller to create a standalone OSX app that runs a GUI I've made. When I enter the following in my terminal:
pyinstaller gui.py
Everything seems to work until I get the following error:
File "/Users/username/anaconda/bin/PyInstaller", line 11, in <module>
sys.exit(run())
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'),
kw.get('clean_build'))
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 212, in __init__
self.__postinit__()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/datastruct.py", line 178, in __postinit__
self.assemble()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 470, in assemble
module_hook.post_graph()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/imphook.py", line 409, in post_graph
self._load_hook_module()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/imphook.py", line 376, in
_load_hook_module
self.hook_module_name, self.hook_filename)
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/hooks/hook-PyQt4.py", line 33, in <module>
(qt_menu_nib_dir('PyQt4'), ''),
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/utils/hooks/qt.py", line 125, in qt_menu_nib_dir
""".format(namespace, path))
Exception:
Cannot find qt_menu.nib for PyQt4
Path checked:
/Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/qt_menu.nib
Which seems strange, since my name is not felipe!
I have a couple of questions:
1) How is it possible that there is a directory under the name felipe on my computer? (I used anaconda to install qt, I don't know whether that has something to do with it?)
2) Up until I get the error message, PyInstaller is looking in the correct folder. Why does it start looking in this vague (vague to me that is) directory I don't know of?
3) I'm quite a novice regarding directories and I can't find mister felipe anywhere on my computer. When I look in the Users folder I just see my own user and an empty "Shared" folder. (I don't know what the shared folder is used for and why it's there.)
4) Based on what I read on the internet, I copied qt_menu-nib to the folder where the script that's supposed to be turned into a standalone is located. What should I do in order to successfully create a standalone from here?
First of all, you face a known issue between PyInstaller and Anaconda: PyInstaller issue #2135. The conversation contains answers to your questions.
1) The path is hardcoded in the wrongly built Qt binary that is provided by Anaconda, see comment from mrady3.
2) PyInstaller loads Qt4-specific hook in order to find resources (qt_menu.nib) that are necessary for running target app. The hook code tries to obtain location of resource directory from the Qt binary itself. Qt binary returns wrong /hardcoded/ path, and after that process fails.
3) See point 1), it was a folder on maintainer's machine. Qt assumes that its installation path is pre-set before building; Anaconda repository hosts a binary that was compiled with another installation path in mind.
4) There could be several possible approaches:
Try installing developer version of PyInstaller from sources, it has some fixes for the above-mentioned issue. Then try building the app again:
git clone https://github.com/pyinstaller/pyinstaller.git
cd pyinstaller
/Users/username/anaconda/bin/python setup.py sdist
conda install dist/PyInstaller-3.3.dev0.tar.bz2
Install Qt4 using homebrew. Local compilation will take a long time:
brew install cartr/qt4/qt
find /usr/local/Cellar/qt -name qt_menu.nib
Edit Qt4 hook at /Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/hooks/hook-PyQt4.py and replace call to qt_menu_nib_dir('PyQt4') with the path from homebrew installation ('/usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib').
Or alternatively, just put qt_menu.nib into expected location:
sudo mkdir -p /Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/
sudo ln -s /usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib /Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/

openssh module in iron python from windows to linux to run commands

I am using openssh in iron python to run commands from windows to linux. I have installed openssh in both the machines and the service is running. I have added keys in authorized users even
conn = SSHConnection(ip_addr, login=name)
ret = conn.run('ls')
or
ret = conn.run(['ls'])
I am getting error as follows
"C:\Program Files\IronPython 2.7\lib\site-packages\openssh_wrapper.py", line 164, in run
"C:\Program Files\IronPython 2.7\Lib\subprocess.py", line 675, in __init__
"C:\Program Files\IronPython 2.7\Lib\subprocess.py", line 887, in _execute_child
Error: [Errno 2] The system cannot find the file specified.
What is wrong in the code?
The line in my copy is
ssh_command = self.ssh_command(interpreter, forward_ssh_agent)
where interpreter, if not specified, defaults to /bin/bash. I think it's saying it doesn't see /bin/bash on the remote machine.

Python - Pygame For android errors

I was following the documentation of pgs4a, where in the build part I got a WindowsError [Error 2].
The Command and Traceback:
C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4>android.py build "C:\Users\karuna\Desktop\Jython\P
ython\pgs4a-0.9.4\mygame" release install
Updating build files.
Traceback (most recent call last):
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 66, in <module>
main()
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 54, in main
build.build(iface, args.argument[0], args.argument[1:])
File "buildlib\build.py", line 301, in build
build_core(iface, directory, commands)
File "buildlib\build.py", line 221, in build_core
subprocess.call([plat.android, "update", "project", "-p", '.', '-t', 'android-8', '-n', versione
d_name])
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 893, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
As obvious,
I am using Windows 7, and have:
Python 2.7.3
JDK
Android Emulator
Device drivers for my Sony Tipo.
Please help!
By the way,
I would prefer to get this running on my phone first. I am thinking of moving to the emulator later(after the tutorial is completed).
Is this question more suitable for https://android.stackexchange.com/?
I am not sure if this is still an issue for you, but I ran into the similar issue recently and managed to solve it so I will just leave a note here.
If anyone gets this kind of error, go to pgs4a folder and android-sdk folder. There, run SDK Manager.exe file. You will see a list of Tools and different android versions. Try to find the version that you are working on and install everything that is 'uninstalled'.
I managed to solve the above issue by installing everything under my current AND previous Android versions. Hope this will help anyone who ran into the same issue!
rename the folder android-sdk-windows to android-sdk

Categories