antiSMASH download_databases.py error in subprocess call - python

I am trying to intall antiSMASH on my research group's server but hitting an issue with the final stage of downloading the relevant databases. The makers provide a script "download_databases.py" to do this for you (see code at https://bitbucket.org/antismash/antismash/src/718da23d059742048bf044a1ed663806051eb0b2/download_databases.py?at=master&fileviewer=file-view-default).
Sadly there seems to be some kind of access issue (I'm not root and sudo doesn't help).
Server is RedHat CentOS 7.2.1511
Command run is "python download_databases.py" in antismash directory. Output is below:
Creating checksum of Pfam-A.hmm.gz
Extraction of Pfam-A.hmm.gz finished successfully.
Traceback (most recent call last):
File "download_databases.py", line 221, in <module>
main()
File "download_databases.py", line 198, in main
compile_pfam(filename)
File "download_databases.py", line 161, in compile_pfam
execute(command)
File "download_databases.py", line 51, in execute
stderr=subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Does anyone with experience of this have an idea of what I need to do? I've tried a local install of Python (2.7) where I have read/write access but that doesn't seem to help as the script is still looking elsewhere for the subprocess script (my own install is at the top of the PATH). Do I possibly need to install something extra with the local install or customise the install locations to include the subprocess etc stuff?
Thanks in advance. I'm no expert and really appreciate the help.
EDIT: Well I feel quite stupid now. Thanks to Hannu for suggesting I check $PATH and what binary the script was trying to execute. It turned out to be one of antiSMASH's dependencies (hmmpress) which I hadn't yet added to the $PATH on this machine. It hadn't occurred to me that it would be required prior to actually running antiSMASH.

Add print commands or something like that to your execute function and see what it tries to execute. The only explanation to get the error in that command is that the script or binary it tries to execute cannot be found.
Try adding a full path to your binary. That alone might solve the issue. Check that there are no typos in the command. Remember commands needs to be a list if it contains parameters, for example ["/usr/bin/foo/myprogram", "-a", "42", "-b", "/tmp/outputfile"] or whatever it is you need to pass to the program.

Related

Packaging/Deploying Maven from Python

Big picture is I'm trying to automate my deployment process of building with maven and deploying to a web logic server. Little picture is I'm using subprocess to see if I can call maven from within python. When I attempt this subprocess mistakes mvn for a file.
Here is my code so far:
import subprocess
def main():
print(subprocess.check_output(["mvn", "-v"]))
if __name__ == '__main__':
main()
And here's my error:
C:\pythondev\python.exe "C:/pythondev/development/deployment scripts/redploy-to-localhost.py"
Traceback (most recent call last):
File "C:/pythondev/development/deployment scripts/redploy-to-localhost.py", line 9, in <module>
main()
File "C:/pythondev/development/deployment scripts/redploy-to-localhost.py", line 5, in main
subprocess.check_output(["a"])
File "C:\pythondev\lib\subprocess.py", line 376, in check_output
**kwargs).stdout
File "C:\pythondev\lib\subprocess.py", line 453, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\pythondev\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\pythondev\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Process finished with exit code 1
Although my issue is with subprocess I'm open to answers that suggest a better alternative.
I ran into the same issue and was hesistant to use shell=True, because the internet tells me this is evil.
When I run where mvn in my cmd.exe, I can see that there are two matches:
mvn, which is a Unix shell-script (it starts with #!/bin/sh),
mvn.cmd, which is a Windows batch file.
I think what happens when you execute mvn something -something in cmd.exe is the following: Windows tries finding an executable called mvn. It finds the mvn file, but realizes that this file is not executable. It then tries finding files like mvn.com, mvn.exe, ... (see the %PATHEXT% system variable). When it finds mvn.cmd, it executes that and everyone is happy.
As far as I understand it, the problem with subprocess.check_output (and subprocess.run, and so on) is that the path-"expansion" via %PATHEXT% is not being performed. So the solution is that you have to give the extension manually and run your command as
print(subprocess.check_output(["mvn.cmd", "-v"]))
Try this it worked for me.
print(subprocess.check_output(["mvn", "-v"], shell=True))

subprocess.check_call error in while trying to generate panoramic picture's for Pannellum

I'm using the Pannellum panorama viewer to do a tour experience of a campus. To improve the support for mobile devices I want to use the Pannellum's multiresolution format using the included python script to generate it form images.
I'm a mac user with very little python knowledge and gotten around to be able to execute the script from terminal (yay!)
The comments on the python script state the requirements:
# Requires Python 3.2+ (or Python 2.7), the Python Pillow package,
# and nona (from Hugin)
I'm running Python 2.7.10, I did install the Pillow package and got the
'nona' executable from the the 'HuginStitchProject.app' (From the package content) which was downloaded from their sourceforge mirror.
When executing the code with python generate.py basketball_court.jpg from the folder contaning the nona executable mentioned earlier, the *.jpg file and generate.py, I get the following error which I am not able to resolve:
Processing input image information...
Generating cube faces...
Traceback (most recent call last):
File "generate.py", line 106, in <module>
subprocess.check_call([args.nona, '-o', os.path.join(args.output, 'face'), os.path.join(args.output, 'cubic.pto')])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 535, in check_call
retcode = call(*popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I see the OSError: [Errno 2] No such file or directory, which file am I missing? Which file is it unable to see?
Any help would be greatly appreciated :)
EDIT: I'm pretty sure that none executable I've got is not the dependency. I don't even know what a executable should look like. Should I be looking for a nona.py, nona.exe, nona.sh or something else?
subprocess.check_call is used to run something in the terminal, but looks like it cannot find the nona executable.
If you edit generate.py and put print(args.nona) before line 106, you'll see what it's trying to call.
Most likely you need to check paths, perhaps put the nona executable in the same dir as generate.py or the one you're running from. Also check it has the executable flag set.
Checking the generate.py source, I see it gets args.nona from its own parameters, or uses a default if you don't explicitly set it (line 59).
The default is set by trying to find an executable called "nona", else set it to None (line 37).

svn 0.3.33 module : Windows Error: [Error 2] : The system cannot find the file specified

I have checked out a folder from SVN to my desktop. Actually I need to extract the information like SVN revision no, URL and status for the specific file in the local working copy. Here is the line of code which I am using to extract those info.
file = svn.local.LocalClient(filePath[i][j])
fileInfo = file.info()
This works perfectly fine in my desktop. But the same thing when I tried to do it in my laptop it throws the following error
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\svn-0.3.22-py2.7.egg\svn\common.py", line 134, in export
self.run_command('export', [self.url_or_path, path])
File "C:\Python27\lib\site-packages\svn-0.3.22-py2.7.egg\svn\common.py", line 29, in run_command
stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 711, in __init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Can anyone pls help me what is wrong? I have installed all the packages which I installed in my desktop. But don't know what is the problem exactly.
Thanks
You need to recheck that the files on your laptop and make sure:
The files actually exist / are the correct files.
They are in the directory you are trying to access them from.
The file names are spelled correctly.
If the system could not find the file specified it means something is missing / misplaced, or the file you are trying to access is not spelled the same as the one you actually want. Its most likely a simple error that could be found by just looking over everything and making sure its all the same as your desktop.
I got the solution for this. Actually the problem was with subversion command line client version. The client version need to be higher than the TortoiseSVN server version, whereas mine was a lower version which created this problem. Now it works fine :)

building and running mitmproxy in python windows: possible at all?

I was attempting to install mitmproxy and run the "mitmproxy" and "mitmdump" from the Scripts folder.
However, I get tons of errors that a lot of modules are not found.
From the error messages I tried to install all the missing modules
Pry
PyOpenSSL
Pyasn
urwid
I stopped after that as I am not sure this will lead me to success.
a) is running and building mitmproxy on windows possible at all?
b) how can I get all the dependant modules and install them?
I reached the point where the package "urwid" is needed. However that fails with: "Unable to find vcvarsall.bat"
EDIT: it seems running mitmproxy is not really possible as the urwid package provides the terminal GUI which does not work for windows. However, I only need mitmdump. When I try running it I get:
C:\Python27\Scripts>C:\Python27\python.exe mitmdump -w out.txt
Traceback (most recent call last): File "mitmdump", line 41, in <module>
proxyconfig = proxy.process_proxy_options(parser, options)
File "C:\Python27\lib\site-packages\libmproxy\proxy.py", line 527, in process_
proxy_options certutils.dummy_ca(cacert)
File "C:\Python27\lib\site-packages\libmproxy\certutils.py", line 44, in dummy_castdin=subprocess.PIPE
File "C:\Python27\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 679, in __init__errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 893, in _execute_childstartupinfo)
WindowsError: [Error 2] System can not find file
C:\Python27\Scripts>
Maybe it can not find this certificate dummy file that is created. However, it didnt create the "mitmproxy-ca-cert.p12"
Help needed
mitmproxy's console interface (ncurses) doesn't run on Windows, although you can get it running under Cygwin. If you don't need an interactive user interface for your specific task, mitmdump (comes with mitmproxy) gets the job done as well. If you want to try out some alpha-quality software, you can also try mitmproxy's mitmweb and open the webinterface at http://localhost:8081/.

Running python scripts with subprocess in windows. Python code checker wrappers from the emacswiki yield the same error

So i'm trying to setup the python code checkers suggested in the emacs wiki. However, I'm unable to run those scripts in my command shell let alone emacs.
The section is found here:
http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc7
And I tried the script located here and here
In both cases I changed the first line from #!usr/bin python with the full path of my python executable and when I run the scripts via
python pylint_etc_wrappers.py someModule.py
or
python pycheckers.py soemModule.py
both boil down to the same error, most likely because they try to open a subprocess. Here's the trace:
Traceback (most recent call last):
File "pycheckers.py", line 254, in <module>
runner.run(source_file)
File "pycheckers.py", line 91, in run
process = Popen(args, stdout=PIPE, stderr=PIPE)
File "C:\devel\Python\Python-2.7\Lib\subprocess.py", line 672, in __init__
errread, errwrite)
File "C:\devel\Python\Python-2.7\Lib\subprocess.py", line 882, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
The second script suggests to change the first line to the path of the interpreter (which I did) and to change the path in the main function which looks something like :
os.environ['PATH'] = \
path.dirname(sys.executable) + ':' + os.environ['PATH']
which was a bit unclear to me. Any ideas?
I have pylint 0.25.1, installed using easy_install (Python 2.7, Win XP). Both pylint and pylint.bat were installed in Python27/Scripts (this directory is in my PATH).
I too get the "The system cannot find the file specified" error when running the pylint_etc_wrapper.py script unchanged.
Running pylint from the script does work if
command = 'pylint'
is changed to
command = 'pylint.bat'
Another way to make it work is to add shell=True to the Popen() call.
I can't really explain all this, but there is an unresolved Python bug that looks like it might be relevant: http://bugs.python.org/issue8557.

Categories