Pretty new to both scapy and python so apologies for what may be a thickheaded question.
I know that it is new and may have issues on Windows but I have successfully installed scapy3 on Windows 2012r2 and Ubuntu Linux. Unfortunately, I actually hope to use it on Windows 7 and am getting the following error message:
Traceback (most recent call last):
File "C:\Python35\Scripts\\scapy", line 25, in <module>
interact()
File "C:\Python35\lib\site-packages\scapy\main.py", line 293, in interact
scapy_builtins = __import__("scapy.all",globals(),locals(),".").__dict__
File "C:\Python35\lib\site-packages\scapy\all.py", line 16, in <module>
from .arch import *
File "C:\Python35\lib\site-packages\scapy\arch\__init__.py", line 95, in <module>
from .windows import *
File "C:\Python35\lib\site-packages\scapy\arch\windows\__init__.py", line 200, in <module>
ifaces.load_from_powershell()
File "C:\Python35\lib\site-packages\scapy\arch\windows\__init__.py", line 151, in load_from_powers
hell
for i in get_windows_if_list():
File "C:\Python35\lib\site-packages\scapy\arch\windows\__init__.py", line 86, in get_windows_if_list
name, value = [ j.strip() for j in i.split(':') ]
ValueError: too many values to unpack (expected 2)
I have searched via google and on stackoverflow but have not found a solution.
Any guidance appreciated.
platform is Windows 7 and python35
Late answer: you are using a fork of scapy that does not officially supports windows 7.
Since very recently, the original secdev/scapy fork supports Python 3, so there is need to keep using the one not supporting windows 7 :-)
Feel free to have a look at
https://github.com/secdev/scapy
Related
I am trying to bring two process up in a windows Nanoserver container using supervisord (pip install supervisor-win )
Everything is setup in supervisord.conf, while starting it I am facing below issue,
C:\data>supervisord -n
C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\options.py:480: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (inc
luding its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
self.warnings.warn(
Traceback (most recent call last):
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 220, in _disable_inheritance_filehandler
import win32api
oduleNotFoundError: No module named 'win32api'
D
uring handling of the above exception, another exception occurred:
T
raceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\python-3.11.1-embed-amd64\Scripts\supervisord.exe\__main__.py", line 7, in <module>
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 403, in main
go(options)
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 415, in go
d.main()
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 77, in main
self.options.make_logger()
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\options.py", line 1221, in make_logger
loggers.handle_file(
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 444, in handle_file
handler = RotatingFileHandler(filename, 'a', maxbytes, backups)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 211, in __init__
self._disable_inheritance_filehandler() # fix file used by others process
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 223, in _disable_inheritance_filehandler
raise ImportWarning("log rotation requires the installation of the \"pywin32\" library.\n"
ImportWarning: log rotation requires the installation of the "pywin32" library.
Download and install from https://github.com/mhammond/pywin32/releases
C:\data>
pywin32 module is already installed (tried reinstall with whl and pip anyway, that did not help)
C:\data>python -m pip show pywin32
Name: pywin32
Version: 305
Summary: Python for Window Extensions
Home-page: https://github.com/mhammond/pywin32
Author: Mark Hammond (et al)
Author-email: mhammond#skippinet.com.au
License: PSF
Location: C:\python-3.11.1-embed-amd64\Lib\site-packages
Requires:
Required-by: pypiwin32, supervisor-win
C:\data>
What could be the issue here? I see less dll files (around 400 only) in C:\Windows\System32 compared to servercore/server image (This is working fine with windows servercore image.)
I'm on MacOS Big Sur trying to run rfcat. I am running anaconda as well and I have set up an environment with Python2.7 when I originally got errors with Python3.x. I have downloaded the pyusb, pyreadline, ipython, PySide2, and the libusb dependancies. Libusb seems to be giving me the most trouble. I keep getting the following error:
Error in resetup():NoBackendError('No backend available',)
Error in resetup():NoBackendError('No backend available',)
Error in resetup():NoBackendError('No backend available',)
^CTraceback (most recent call last):
File "/opt/anaconda3/envs/rftools/bin/rfcat", line 4, in <module>
__import__('pkg_resources').run_script('rfcat==1.9.5', 'rfcat')
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1469, in run_script
exec(script_code, namespace, namespace)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat-1.9.5-py2.7.egg/EGG-INFO/scripts/rfcat", line 63, in <module>
File "build/bdist.macosx-10.7-x86_64/egg/rflib/__init__.py", line 208, in interactive
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_nic.py", line 103, in __init__
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_usb.py", line 93, in __init__
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_usb.py", line 238, in resetup
KeyboardInterrupt
From my research so far, backend is how pyusb refers to libusb, libusb1 or openusb. It is unable to find the libusb within the environment. I did a little tracking and found that ultimately, the find_library() function is found in ctypes in util.py. It refers to the executable path for MacOS with #executable_path/../lib/libusb%s..... I tried to put libusb into a folder on my executable path to hopefully match this functions search, and still got the same errors. I then found instructions on inputting a custom path for the backend for pyusb here. This appears to be a method where you input the device and backend information at the beginning of your program. The code I inserted is as follows:
import usb.core
import usb.backend.libusb1 as libusb1
backend = libusb1.get_backend(find_library=lambda x: "/path/to/file/lib/libusb-1.0.0.dylib")
dev = usb.core.find(idVendor=“MyVID”, idProduct=“MyPID”, backend=backend)
This induced a similar error but with a different traceback when I placed the code in rflib.init and the rfcat codes:
Traceback (most recent call last):
File "/opt/anaconda3/envs/rftools/bin/rfcat", line 4, in <module>
__import__('pkg_resources').run_script('rfcat==1.9.5', 'rfcat')
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1469, in run_script
exec(script_code, namespace, namespace)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat-1.9.5-py2.7.egg/EGG-INFO/scripts/rfcat", line 12, in <module>
File "build/bdist.macosx-10.7-x86_64/egg/rflib/__init__.py", line 15, in <module>
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb/core.py", line 1304, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
I have since reset things back to how I started and am still getting the original error listed above.
I think this largely has to do with the anaconda environment, which I can of course remove. I want to try to find a way to make this work though. Is there a better method to help rfcat find the libusb as required? Another possible solution is resolving the actual executable_path. Does anyone know how to find the executable_path?
In case it helps, I will list the default locations for commands and files.
rfcat: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat
pyusb: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb
ctypes: /opt/anaconda3/envs/rftools/lib/python2.7/ctypes
libusb: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb/lib
I am running a flask application using plotly for some of my charting figures, and it runs fine on my work pc.
I have just tried to run it on my personal pc and on starting the local host server I am getting the following message:
Traceback (most recent call last):
File "controller.py", line 14, in <module>
from plotly.offline import plot
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\__init__.py", line 31, in <module>
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\plotly\__init__.py", line 10, in <module>
from . plotly import (
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\plotly\plotly.py", line 29, in <module>
from plotly import exceptions, files, session, tools, utils
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 403, in <module>
#utils.template_doc(**get_config_file())
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 241, in get_config_file
ensure_local_plotly_files() # make sure what's there is OK
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 94, in ensure_local_plotly_files
utils.save_json_dict(fn, contents)
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\utils.py", line 61, in save_json_dict
with open(filename, "w") as f:
IOError: [Errno 13] Permission denied: 'C:\\Users\\StuJ7\\.plotly\\.credentials'
So it's obvious from the error message that it is an issue with permissions regarding the .plotly.credentials file - but I have assigned myself full permissions to the whole .plotly folder through the security settings and I have also pip installed plotly as an administrator.
I've tried extensive Googling , but there doesn't seem to be much windows related advice regarding this particular issue.
Can anyone suggest how I can get this to work.
Hi text mining champions,
I'm using Anaconda with NLTK v3.2 on Windows 10.(client's environment)
When I try to POS tag, I keep getting a URLLIB2 error:
URLError: <urlopen error unknown url type: c>
It seems urllib2 is unable to recognize windows paths? How can I work around this?
The command is simple as:
nltk.pos_tag(nltk.word_tokenize("Hello World"))
edit:
There is a duplicate question, however I think the answers obtained here by manan and alvas are a better fix.
EDITED
This issue has been resolved from NLTK v3.2.1. Upgrading your NLTK version would resolve the issue, e.g. pip install -U nltk.
I faced the same issue and the error encountered was as follows;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\__init__.py", line 110, in pos_tag
tagger = PerceptronTagger()
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py", line 141, in __init__
self.load(AP_MODEL_LOC)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py", line 209, in load
self.model.weights, self.tagdict, self.classes = load(loc)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\data.py", line 801, in load
opened_resource = _open(resource_url)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\data.py", line 924, in _open
return urlopen(resource_url)
File "C:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 391, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 414, in _open
'unknown_open', req)
File "C:\Python27\lib\urllib2.py", line 369, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1206, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib2.URLError: <urlopen error unknown url type: c>
The URLError that you mentioned was due to a bug in the perceptron.py file within the NLTK library for Windows.
In my machine, the file is at this location
C:\Python27\Lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py
(Basically look at an equivalent location within yours wherever you have the Python27 folder)
The bug was basically in the code to find the corresponding location for the averaged_perceptron_tagger within your machine. One can have a look at the line 801 and 924 mentioned in the data.py file regarding this.
I think the NLTK developer community recently fixed this bug in the code. Have a look at this commit made to their code a few days back.
https://github.com/nltk/nltk/commit/d3de14e58215beebdccc7b76c044109f6197d1d9#diff-26b258372e0d13c2543de8dbb1841252
The snippet where the change was made is as follows;
self.tagdict = {}
self.classes = set()
if load:
AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
self.load(AP_MODEL_LOC)
# Initially it was:AP_MODEL_LOC = str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
def tag(self, tokens):
Updating the file to the most recent commit worked for me and was able to use the nltk.pos_tag command. I believe this would resolve your problem as well (assuming you have everything else set up).
EDITED
This issue has been resolved from NLTK v3.2.1. Please upgrade your NLTK!
First read #MananVyas answer for the why:
https://stackoverflow.com/a/35902494/610569
Here's the how, without downgrading to NLTK v3.1, using NLTK 3.2, you can use this "hack":
>>> from nltk.tag import PerceptronTagger
>>> from nltk.data import find
>>> PICKLE = "averaged_perceptron_tagger.pickle"
>>> AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
>>> tagger = PerceptronTagger(load=False)
>>> tagger.load(AP_MODEL_LOC)
>>> pos_tag = tagger.tag
>>> pos_tag('The quick brown fox jumps over the lazy dog'.split())
[('The', 'DT'), ('quick', 'JJ'), ('brown', 'NN'), ('fox', 'NN'), ('jumps', 'VBZ'), ('over', 'IN'), ('the', 'DT'), ('lazy', 'JJ'), ('dog', 'NN')]
I faced the same issue a while back.
Solution:
nltk.download('averaged_perceptron_tagger')
I'm new to Python and NLTK. I've been trying to find a solution to my problem but have not found one yet and was hoping someone could help me.
I'm currently running 64bit Windows 8. I've followed the instruction in the NLTK website (http://www.nltk.org/install.html). I might have installed a 64bit version Python in the first place but have removed it and reinstall 32bit version Python. Now I'm having the following problem:
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import nltk
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import nltk
File "C:\Python27\lib\site-packages\nltk\__init__.py", line 117, in <module>
from nltk.align import *
File "C:\Python27\lib\site-packages\nltk\align\__init__.py", line 15, in <module>
from nltk.align.ibm1 import IBMModel1
File "C:\Python27\lib\site-packages\nltk\align\ibm1.py", line 18, in <module>
from nltk.corpus import comtrans
File "C:\Python27\lib\site-packages\nltk\corpus\__init__.py", line 64, in <module>
from nltk.tokenize import RegexpTokenizer
File "C:\Python27\lib\site-packages\nltk\tokenize\__init__.py", line 62, in <module>
from nltk.data import load
File "C:\Python27\lib\site-packages\nltk\data.py", line 74, in <module>
if os.path.expanduser('~/') != '~/':
File "C:\Python27\lib\ntpath.py", line 310, in expanduser
return userhome + path[i:]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xac in position 9: ordinal not in range(128)
>>>
Any ideas?
I solve this by changing my operating system locale for non-Unicode programs:
1 – Go to Control Panel
2 – Click “Clock, Language and Region”
3 – Click “Regional and Language Options”
4 – Go under “Administrative” tab
5 – current system locale (for non-Unicode) is displayed, to change it click “Change system locale”
6 – Then just choose English! After a reboot, done!