PyInstaller issue, not running after building - python

I have a wx Python program which I have attempting to build into a .exe with PyInstaller. I have installed Pywin32 and Pyinstaller, I've used both the below to package up the Python file.
pyinstaller andro.py
pyinstaller -F andro.py
Both .exe files when double clicked flash up a cmd box briefly then disappear.
Trying to run both from cmd gives me the error:
Traceback (most recent call last):
File "<string>", line 1737, in <module>
File "c:\pentesting\andro\build\andro\out00-PYZ.pyz\wx._core", line 8628, in __in
it__
File "c:\pentesting\andro\build\andro\out00-PYZ.pyz\wx._core", line 8196, in _BootstrapApp
File "<string>", line 1732, in OnInit
File "<string>", line 298, in __init__
File "<string>", line 308, in startConf
File "<string>", line 835, in deviceExists
File "c:\pentesting\andro\build\andro\out00-PYZ.pyz\subprocess", line 710, in __i
nit__
File "c:\pentesting\andro\build\andro\out00-PYZ.pyz\subprocess", line 958, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
Line 1732 is:
frame = Main(None, -1, 'Andro')
Line 298 is:
self.startConf()
Line 308 is:
stdout = self.deviceExists()
Line 835 is:
p = Popen(params, shell=False, stdout=subprocess.PIPE)
Following the trail, they all lead to the deviceExists() function, specifically line 835, the 'p = Popen' line:
def deviceExists(self):
params = [toolsDir + "\\adb.exe", "devices"]
p = Popen(params, shell=False, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
return stdout
The program runs and works fine when launched from cmd, python andro.py, so unsure of the problem, is anyone able to offer any idea?

Related

gclient sync failed when downloading chromium

I'm doing gclient sync in linux and windows and in both I'm getting the same error after around 15 min.
Traceback (most recent call last):
File "/home/jgd/dev/depot_tools/gclient.py", line 2295, in <module>
sys.exit(main(sys.argv[1:]))
File "/home/jgd/dev/depot_tools/gclient.py", line 2281, in main
return dispatcher.execute(OptionParser(), argv)
File "/home/jgd/dev/depot_tools/subcommand.py", line 252, in execute
return command(parser, args[1:])
File "/home/jgd/dev/depot_tools/gclient.py", line 2030, in CMDsync
ret = client.RunOnDeps('update', args)
File "/home/jgd/dev/depot_tools/gclient.py", line 1340, in RunOnDeps
work_queue.flush(revision_overrides, command, args, options=self._options)
File "/home/jgd/dev/depot_tools/gclient_utils.py", line 1047, in run
self.item.run(*self.args, **self.kwargs)
File "/home/jgd/dev/depot_tools/gclient.py", line 766, in run
self.ParseDepsFile()
File "/home/jgd/dev/depot_tools/gclient.py", line 562, in ParseDepsFile
gclient_eval.Check(deps_content, filepath, global_scope, local_scope)
File "/home/jgd/dev/depot_tools/gclient_eval.py", line 240, in Check
result_scope = _gclient_exec(content, global_scope, filename=path)
File "/home/jgd/dev/depot_tools/gclient_eval.py", line 185, in _gclient_exec
_visit_in_module(stmt)
File "/home/jgd/dev/depot_tools/gclient_eval.py", line 169, in _visit_in_module
value = _gclient_eval(node.value, global_scope, filename=filename)
File "/home/jgd/dev/depot_tools/gclient_eval.py", line 146, in _gclient_eval
return _convert(node_or_string)
File "/home/jgd/dev/depot_tools/gclient_eval.py", line 145, in _convert
getattr(node, 'lineno', '<unknown>')))
ValueError: unexpected AST node: <_ast.Num object at 0x1cf5d10> Num(n=1) (file '/home/jgd/dev/jgd/webrtc/src/chromium/src/buildtools/DEPS', line 1)
Error: Command '/usr/bin/python -u src/sync_chromium.py --target-revision 316b880c55452eb694a27ba4d1aa9e74ec9ef342' returned non-zero exit status 1 in /home/jgd/dev/jgd/webrtc
Both are fresh installed and I have no idea about what is happening, it is the first time that this occurs to me. Know anyone how to solve it?
EDIT: The DEPS file that appears in error trace is the following:
recursion = 1
use_relative_paths = True
vars = {
"git_url": "https://chromium.googlesource.com",
"clang_format_rev": "0ed791d1387a3c9146ea6c453c646f3c0fc97784", # r282136
"libcxx_revision": "b1ece9c037d879843b0b0f5a2802e1e9d443b75a", # r256621
"libcxxabi_revision": "0edb61e2e581758fc4cd4cd09fc588b3fc91a653", # r256323
}
deps = {
"clang_format/script":
Var("git_url") + "/chromium/llvm-project/cfe/tools/clang-format.git#" +
Var("clang_format_rev"),
"third_party/libc++/trunk":
Var("git_url") + "/chromium/llvm-project/libcxx.git" + "#" +
Var("libcxx_revision"),
"third_party/libc++abi/trunk":
Var("git_url") + "/chromium/llvm-project/libcxxabi.git" + "#" +
Var("libcxxabi_revision"),
}
AFAIK this is auto-generated.
sync_chromium.py was removed back in December, replaced by a more efficient and far smaller download package. I suggest you follow the instructions at https://webrtc.org/native-code/development and get a newer checkout. It should be less likely to have download problems.
The issue here is the version of Python used. As you can see in command error prompt, the version that I have used is not 2.7+ as recomended in chromium website. Doing the change from Python to Python2.7 solve the issue.

Python: Error in tree graph plotting coinor

I get a problem using coinor to display a tree graph. In specific the line "prob.Tree.display". The problem solves with/without this line.
Here's the error:
Traceback (most recent call last):
File "C:/Users/Timothy/Desktop/desktop/uni/fourth year/sem1/761/assign1/knapsack_func1.py", line 77, in <module>
solve_knapsack(prob)
File "C:/Users/Timothy/Desktop/desktop/uni/fourth year/sem1/761/assign1/knapsack_func1.py", line 59, in solve_knapsack
prob.Tree.display()
File "C:\Python2711\lib\site-packages\coinor\gimpy\graph.py", line 1752, in display
window.set_dotcode(self.to_string())
File "C:\Python2711\lib\site-packages\xdot.py", line 2010, in set_dotcode
if self.widget.set_dotcode(dotcode, filename):
File "C:\Python2711\lib\site-packages\xdot.py", line 1541, in set_dotcode
xdotcode = self.run_filter(dotcode)
File "C:\Python2711\lib\site-packages\xdot.py", line 1523, in run_filter
universal_newlines=True
File "C:\Python2711\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python2711\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Process finished with exit code 1
Heres the code which is getting the error:
if prob.display_mode != 'off':
print "Number of nodes =", len(prob.Tree.get_node_list())
if (prob.display_mode == 'pygame') or (prob.display_mode == 'xdot'):
prob.Tree.display()
Can provide more code if needed
Thanks

Python: Broken Pipe Error For PyNomo Example (in function Nomographer)

I am using pycharm on Python 2.7. I have installed PyNomo. I am trying to run this small example from the official site. Code is available on the link, I have simply copy pasted it. I get the following error:
Aligning with tag A
Traceback (most recent call last):
File "/home/darshil/Desktop/Caltech Summer Internship/Radiation Ononcology Data/DB/rad3/pynomo_temp.py", line 71, in <module>
Nomographer(main_params)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomographer.py", line 203, in __init__
wrapper.draw_nomogram(c,params['post_func'])
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 213, in draw_nomogram
block.draw(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 445, in draw
atom.draw(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 2503, in draw
axis_appear=p,base_start=base_start,base_stop=base_stop)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_axis.py", line 123, in __init__
self.draw_axis(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_axis.py", line 1067, in draw_axis
c.text(x,y,ttext,attr+[text_color])
File "/usr/local/lib/python2.7/dist-packages/pyx/canvas.py", line 324, in text
return self.insert(self.texrunner.text(x, y, atext, *args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 1194, in text
self.execute(expr, self.defaulttexmessagesdefaultrun + self.texmessagesdefaultrun + texmessages)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 951, in execute
self.defaulttexmessagesstart + self.texmessagesstart)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 1005, in execute
self.texinput.write(self.expr)
IOError: [Errno 32] Broken pipe
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 748, in _cleantmp
texrunner.texinput.write("\n\\end\n")
IOError: [Errno 32] Broken pipe
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 748, in _cleantmp
texrunner.texinput.write("\n\\end\n")
IOError: [Errno 32] Broken pipe
Process finished with exit code 1
The error is in the final line of the code:
Nomographer(main_params)
I have looked at other questions with "broken pipe error": here,here, and here. But none of them are helpful to me.
Any indication on how to solve would be very helpful.
PyNomo uses a TeX installation to typeset text. Maybe this is missing resulting in a broken pipe. You need to be able to run a file hello.tex with the content Hello, world!\bye on a command line tex hello.tex. It should result in a file hello.dvi. If not you need to install a TeX distribution like TeXLive.

Execute Robot Framework file from python script

from subprocess import call
import os
call(['robot '+os.getcwd()+'\\aaa.robot'])
file_dir: D:/aaa/test/aaa.robot
script for now in same dir
Output:
Traceback (most recent call last):
File "__init.py", line 7, in <module>
call(['robot '+os.getcwd()+'\\aaa.robot'])
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 710, in __init_
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execut
startupinfo)
WindowsError: [Error 2] Nie mo┐na odnalečŠ okreťlonego pliku
I just cant handle it. I dont get why in python tunning anything is so complicated :(
I want same result as this line (written directly to cmd):
/>robot aaa.robot
Here is another way
import robot
logFile = open('mylog.txt', 'w')
robot.run("tmp.robot",stdout=logFile)
subprocess expects a list but you're inputting a string ('robot '+os.getcwd()+'\\aaa.robot').
Try:
call(['C:/Python27/python.exe', '-m', 'robot', 'D:/aaa/test/aaa.robot'])
or
call(['C:/Python27/Scripts/robot.bat', 'D:/aaa/test/aaa.robot'])

Why am I getting [Errno 7] Argument list too long and OSError: [Errno 24] Too many open files when using mrjob v0.4.4?

It seems like the nature of the MapReduce framework is to work with many files. So when I get errors that tell me I'm using too many files, I suspect I'm doing something wrong.
If I run the job with the inline runner and three directories, it works:
$ python mr_gps_quality.py /Volumes/Logs/gps/ByCityLogs/city1/0[1-3]/*.log -r inline --no-output --output-dir city1_results/gps_quality/2015/03/
But if I run it using the local runner (and the same three directories), it fails:
$ python mr_gps_quality.py /Volumes/Logs/gps/ByCityLogs/city1/0[1-3]/*.log -r local --no-output --output-dir city1_results/gps_quality/2015/03/
[...output clipped...]
> /Users/andrewsturges/sturges/mr/env/bin/python mr_gps_quality.py --step-num=0 --mapper /var/folders/32/5vqk9bjx4c773cpq4pn_r80c0000gn/T/mr_gps_quality.andrewsturges.20150604.170016.046323/input_part-00249 > /var/folders/32/5vqk9bjx4c773cpq4pn_r80c0000gn/T/mr_gps_quality.andrewsturges.20150604.170016.046323/step-k0-mapper_part-00249
Traceback (most recent call last):
File "mr_gps_quality.py", line 53, in <module>
MRGPSQuality.run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/job.py", line 494, in run
mr_job.execute()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/job.py", line 512, in execute
super(MRJob, self).execute()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/launch.py", line 147, in execute
self.run_job()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/launch.py", line 208, in run_job
runner.run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/runner.py", line 458, in run
self._run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/sim.py", line 182, in _run
self._invoke_step(step_num, 'mapper')
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/sim.py", line 269, in _invoke_step
working_dir, env)
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/local.py", line 150, in _run_step
procs_args, output_path, working_dir, env)
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/local.py", line 253, in _invoke_processes
cwd=working_dir, env=env)
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/local.py", line 76, in _chain_procs
proc = Popen(args, **proc_kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1197, in _execute_child
errpipe_read, errpipe_write = self.pipe_cloexec()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1153, in pipe_cloexec
r, w = os.pipe()
OSError: [Errno 24] Too many open files
Furthermore, if I go back to using the inline runner and include even more directories (11 total) in my input, then I get a different error again:
$ python mr_gps_quality.py /Volumes/Logs/gps/ByCityLogs/city1/*/*.log -r inline --no-output --output-dir city1_results/gps_quality/2015/03/
[...clipped...]
Traceback (most recent call last):
File "mr_gps_quality.py", line 53, in <module>
MRGPSQuality.run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/job.py", line 494, in run
mr_job.execute()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/job.py", line 512, in execute
super(MRJob, self).execute()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/launch.py", line 147, in execute
self.run_job()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/launch.py", line 208, in run_job
runner.run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/runner.py", line 458, in run
self._run()
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/sim.py", line 191, in _run
self._invoke_sort(self._step_input_paths(), sort_output_path)
File "/Users/andrewsturges/sturges/mr/env/lib/python2.7/site-packages/mrjob/runner.py", line 1202, in _invoke_sort
check_call(args, stdout=output, stderr=err, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 537, in check_call
retcode = call(*popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 7] Argument list too long
The mrjob docs include a discussion of the differences between the inline and local runners, but I don't understand how it would explain this behavior.
Lastly, I'll mention that the number of files in the directories I'm globbing isn't huge (acknowledgement):
$ find . -maxdepth 1 -mindepth 1 -type d | while read dir; do printf "%-25.25s : " "$dir"; find "$dir" -type f | wc -l; done | sort
./01 : 236
./02 : 169
./03 : 176
./04 : 185
./05 : 176
./06 : 235
./07 : 275
./08 : 265
./09 : 186
./10 : 171
./11 : 161
I don't think this has to do with the job itself, but here it is:
from mrjob.job import MRJob
import numpy as np
import geohash
class MRGPSQuality(MRJob):
def mapper(self, _, line):
try:
lat = float(line.split(',')[1])
lng = float(line.split(',')[2])
horizontalAccuracy = float(line.split(',')[4])
gh = geohash.encode(lat, lng, precision=7)
yield gh, horizontalAccuracy
except:
pass
def reducer(self, key, values):
# Convert the generator straight back to array:
vals = np.fromiter(values, float)
count = len(vals)
mean = np.mean(vals)
if count > 50:
yield key, [count, mean]
if __name__ == '__main__':
MRGPSQuality.run()
The problem for "Argument list too long" is not the job or python, its bash. The asterisk in your command line to kick off the job expands out to every file that matches which is a really long command line and exceeds bash limit.
The error has nothing to do with ulimit but the error "Too many open files" is to do with ulimit, so you bump into the ulimit if the command were to actually run.
You can check the shells limit like this (if you are interested)...
getconf ARG_MAX
To get around the max args problem, you can concatenate all the files into one by doing this.
for f in *; do cat "$f" >> ../directory/bigfile.log; done
Then run your mrjob pointed at the big file.
If its a lot of files you can use multiple threads to concat the file using gnu parallel because above command is single thread and slow.
ls | parallel -m -j 8 "cat {} >> ../files/bigfile.log"
*Change 8 to the amount of parallelism you want

Categories

Resources