i installed python-nmap-0.1.4.tar.gz in pyhton27 in window. When i ran this http://codepad.org/vTu1Uw7I script, i got a few error. What those error mean?. Are those error happened because i used python-nmap-0.1.4.tar.gz in windows?.
Here is the error
Traceback (most recent call last):
File "C:/Python27/Lib/site-packages/nmap/run-nmap.py", line 3, in <module>
nm = nmap.PortScanner() # instantiate nmap.PortScanner object
File "C:/Python27/Lib/site-packages/nmap\nmap.py", line 118, in __init__
p = subprocess.Popen(['nmap', '-V'], bufsize=10000, stdout=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
Here is the subprocess.py script
http://codepad.org/SpbV8muR
Seems that python-nmap is meant to be run on Linux… but you can still try to make it work on Windows. The problem is that it is trying to call nmap but the binary is not found in PATH.
Add the directory with nmap executable to you PATH variable. Here is a HOWTO.
Related
I'm running a python script that exports xml from a database, converts the record to PDF, then attempts to upload both the xml and pdf files to a github repository. The export and pdf conversion work fine, but the process then hangs and outputs the following error message:
Traceback (most recent call last):
File "asExportIncremental.py", line 394, in <module>
main()
File "asExportIncremental.py", line 320, in main
gitPush()
File "asExportIncremental.py", line 308, in gitPush
repo.push()
File "C:\Python27\lib\site-packages\gittle\gittle.py", line 343, in push
return self.push_to(origin_uri, branch_name, progress)
File "C:\Python27\lib\site-packages\gittle\gittle.py", line 338, in push_to
progress=progress
File "C:\Python27\lib\site-packages\dulwich\client.py", line 440, in send_pack
proto, unused_can_read = self._connect('receive-pack', path)
File "C:\Python27\lib\site-packages\dulwich\client.py", line 893, in _connect
port=self.port, username=self.username)
File "C:\Python27\lib\site-packages\dulwich\client.py", line 758, in run_command
stdout=subprocess.PIPE)
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 2] The system cannot find the file specified
My problem is that I'm not exactly sure where the script is failing. To which file is "WindowsError: [Error 2] The system cannot find the file specified" referring? How do I fix it? Thanks!
The script calls gittle (high-level python git library) which executes dulwich (low-level python git wrapper) which runs ssh and fails. It seems ssh.exe is not in your PATH.
Under MacOSX Sierra, and XQuartz 2.7.11, Python 2.7. I was able to install dryscrape and its required other python packages. I've tried quite a few methods to get some simple code working, but I can't seem to get it working. Here is the simple code:
#!/usr/bin/python
#coding: utf-8
import dryscrape
testurl = 'http://avi.im/stuff/js-or-no-js.html'
dryscrape.start_xvfb()
session = dryscrape.Session()
session.visit(testurl)
exit()
You can see it is a simple python script file. It fails on either the start_svfb() or the Session() line. I can post the errors and such, but can I start a discussion on simply what check list should I setup, run, and test to make sure the X11 environment is right? Do I run the script under OS X terminal or XQuartz? What am I missing? etc.?
Thanks in advance, Lucas.
here is the last traceback from python:
Traceback (most recent call last):
File "./fred.py", line 19, in
session = dryscrape.Session()
File "build/bdist.macosx-10.12-intel/egg/dryscrape/session.py", line 22, in __init__
File "build/bdist.macosx-10.12-intel/egg/dryscrape/driver/webkit.py", line 30, in __init__
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 230, in __init__
self.conn = connection or ServerConnection()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 507, in __init__
self._sock = (server or get_default_server()).connect()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 450, in get_default_server
_default_server = Server()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 416, in __init__
stderr = subprocess.PIPE)
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
When i try to run the scan operation using the wifi library as mentioned in the documentation, i get the following error.
(lsbaws)Keshav:bin root# wifi scan
Traceback (most recent call last):
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/bin/wifi", line 202, in <module>
args.func(args)
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/bin/wifi", line 51, in scan_command
print_table([[cell.signal, cell.ssid, 'protected' if cell.encrypted else 'unprotected'] for cell in Cell.all(args.interface)])
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/lib/python2.7/site-packages/wifi/scan.py", line 29, in all
stderr=subprocess.STDOUT)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I figured that this python wifi library does not work on mac.
An alternative to do wifi scanning is using the tool that comes in mac called airports.
To start using the tool -
$ cd /usr/sbin
$ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
The airports -I flag is useful
Also just typing airports will open up the partly explicit manual page
Refrence link - Airports Example
So I have a python script that produces a networkx graph and exports it as .graphml and I want script to also be able to open cytoscape with the network loaded without any work on the users part. I understand:
cytoscape.bat -N C:\Somepath\with\a\networkx.graphml
and it works fine when I use it. As does:
cd "C:\Program Files\Cytoscape_v3.0.0"
cytoscape.bat
However, I can't seem to get either os.system or subprocess to run properly, my current configuration is:
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0")
stdout, stderr = p.communicate()
But the throws a file-not-found-exception.
I've been reading up on other stackoverflow posts and python docs on running .bats and doing cmd operations, and can get the basics to work. However, this seems somewhat more complicated, and I'm not sure where I'm going wrong!
As requested I exceptions:
The file not found and incorrect path exceptions:
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="\"C:/Program Files/Cytoscape_v3.0
.0\"")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 267] The directory name is invalid
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0
")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
A slightly different JVM error, it is produced by this code:
os.system("\"C:/Program Files/Cytoscape_v3.0.0/cytoscape.bat\"")
Error: missing `server' JVM at `C:\Program Files (x86)\Java\jre7\bin\server\jvm.
dll'.
Please install or use the JRE or JDK that contains these missing components.
C:\Program Files\Cytoscape_v3.0.0
From the documentation:
"If cwd is not None, the child’s current directory will be changed to cwd before it is executed. Note that this directory is not considered when searching the executable, so you can’t specify the program’s path relative to cwd."
You have to pass the full path of the command to subprocess.Popen.
I am trying to run an existing python code, and having issues with it.
This program required npm program installed and which is installed at C:\Program Files\nodejs\npm in my computer. When I run the following code, as a part of the whole program, it throws errors.
def popen_results(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
return proc.communicate()[0]
def installed():
"""docstring for npm_installed"""
return popen_results(["which", "npm"]).strip()
This is the complete stack of the error thrown--
Checking for node and dependencies
Traceback (most recent call last):
File "deploy\deploy.py", line 344, in <module>
main()
File "deploy\deploy.py", line 287, in main
if not check_deps():
File "deploy\deploy.py", line 201, in check_deps
return npm.check_dependencies()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
38, in check_dependencies
if not installed():
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
13, in installed
return popen_results(["which", "npm"]).strip()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
8, in popen_results
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
File "C:\python25\lib\subprocess.py", line 594, in __init__
errread, errwrite)
File "C:\python25\lib\subprocess.py", line 822, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
I agree with martineau, it is unable to find which. The script may have been written with the assumption it was going to be run in a unix environment which would most likely have the "which" command available and in the default PATH. Since it looks like you're running this on Windows, I don't think it's going to work.
It looks like there is some alternatives to which on Windows though, discussed here: Is there an equivalent to which on Windows?