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
Related
I am working on a script to analysis proteins. One of the def if for creating a makeblastdb, and then use it to carry out blast. The code is as below:
import subprocess
from Bio import SeqIO
from Bio.Blast.Applications import NcbiblastnCommandline
def blast_file(input_data_files, db_files, output):
input_data_files = opts.input_file + '/protein_extracted_file.fa'
db_files = opts.input_file +'/alleles_reference_db'
cmd = ["makeblastdb", "-in", db_files, "-dbtype", "prot", "-parse_seqids", "-out", output + "/temporary_db",
"-title", "temporary_db"]
my_file = subprocess.Popen(cmd)
my_file.wait()
blasttn_cline = NcbiblastnCommandline(query=input_data_files, subject=db_files, evalue=0.001, outfmt=5,
out=output + '/blast_output.xml')
blasttn_cline()
The script works well until it get to the above def, and I get the error message:
Traceback (most recent call last):
**> File "open.py", line 234, in <module>
> main() File "open.py", line 229, in main
> blast_file(input_data_files, db_files, output) File "open.py", line 165, in blast_file
> my_file = subprocess.Popen(cmd)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 709, in __init__
> restore_signals, start_new_session) File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 997, in
> _execute_child
> startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified**
How can I make this to work for python3? Originally the script was written in python2.7, and I have updated most of it but I am stuck in this area. Any suggestion to update it?
I have many rasters that im trying to combine in order to produce contours. They are in the .bil format so I understand that i need to translate them using gdal first but none of my attempts have worked.
I have tried to used gdal_translate and gdal_merge with no success. Below is the a sample of two .bils i tried to merge.
import subprocess
import sys
import gdal
#imagea ='C:\\Users\\jeswa\\Desktop\\New folder\\N34_E\\n34_e024_1arc_v3.bil'
#imageb ='C:\\Users\\jeswa\\Desktop\\New folder\\N34_E\\n34_e025_1arc_v3.bil'
#output = 'C:\\Users\\jeswa\\Desktop\\test'
#subprocess.call(['gdal_merge', '-o', output, imagea, imageb])
Traceback (most recent call last):
File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\OSGEO4~1\apps\Python37\lib\subprocess.py", line 304, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\OSGEO4~1\apps\Python37\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\OSGEO4~1\apps\Python37\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
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.
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'])
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?