I am trying to run Sulley's (the fuzzer) "network_monitor.py" on an Ubuntu vm. Everytime I do, I get the following error.
pcapy.PcapError: No valid interfaces to open
I believe that this has little to do with the code I am running it in, because when I run
python
>>> import pcapy
>>> devices = pcapy.findalldevs()
I get the same error
Any hints on what's going on would be amazing. Thanks so much in advance
Try to use it with sudo.
Pcapy, AFAIK, needs special rights to access interfaces.
mycode.py:
import pcapy
devices = pcapy.findalldevs()
sudo python mycode.py
Related
I had an issue like this on my Nano:
profiles = [ SERIAL_PORT_PROFILE ],
File "/usr/lib/python2.7/site-packages/bluetooth/bluez.py", line 176, in advertise_service
raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')
I tried adding compatibility mode in the bluetooth.service file, reloading daemon, restarting bluetooth and then adding a serial port by doing
sudo sdptool add SP
These steps work fine on my ubuntu 20.04 laptop, but on jetpack 4.5.1, they don’t. And I checked also, they don’t work on jetson NX either.
I am really curious on how to solve this issue, otherwise, another way to use bluetooth inside a python code is welcomed.
Thanks
You might want to have a look at the following article which shows how to do the connection with core Python Socket library
https://blog.kevindoran.co/bluetooth-programming-with-python-3/.
The way BlueZ does this now is with the Profile API.
There is a Python example of using the Profile API at https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/test-profile
hciattach, hciconfig, hcitool, hcidump, rfcomm, sdptool, ciptool, and gatttool were deprecated by the BlueZ project in 2017. If you are following a tutorial that uses them, there is a chance that it might be out of date and that Linux systems will choose not to support them.
The solution was in the path of the bluetooth configuration file (inspired from this https://developer.nvidia.com/embedded/learn/tutorials/connecting-bluetooth-audio)
this answer : bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')
is not enough for jetson devices (jetpack). Although I didn't test if it works without changing the file mentioned in this link.
There is a .conf file that needs to be changed also : /lib/systemd/system/bluetooth.service.d/nv-bluetooth-service.conf
modify :
ExecStart=/usr/lib/bluetooth/bluetoothd -d --noplugin=audio,a2dp,avrcp
to :
ExecStart=/usr/lib/bluetooth/bluetoothd -C
after that it is necessary to do:
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
Tested on jetson Nano and NX with jetpach 4.5.1
Thanks for the help !
I have a DeLorme Earthmate LT-40 USB GPS device that I used years ago with a Windows XP program. Out of curiosity I plugged it into my Raspberry Pi to see if I could read the data. I've managed to see data using sudo gpsmon at the command prompt so I would like to take this a step further and write a Python program to read the data. Not knowing very much about Python I've searched YouTube and google for possible solutions. It looks like that I need to import pynmea2. I used pip install pynmea2 to install the module. I keep getting
"ModuleNotFoundError: No module named pynmea2"
when I try to run my script. I tried to reinstall pynmea2 again which gave me
Requirement already satisfied: pynmea2 in ./.local/lib/python2.7/site-packages(1.15.0).
I don't understand what I'm doing wrong. Any help would be greatly appreciated. Thank you.
I have the older version LT-20 of that GPS and usually it presents itself as ttyUSB0 (in my case) when I plug it on Raspberry.
Just do a dmesg command to see in which port it is being recognized, then you can do a cat /dev/ttyUSB0 command and you see all the messages coming from your GPS. The messages start with a $GP for each type of frame. See detailed $GP description at: http://aprs.gids.nl/nmea/ .
Then from your python program, you can open /dev/ttyUSB0 as a file (as read only) and handle each frame and interpetting it according to its format.
Best regards
Flavio
I have a Windows machine in which some Python code works, but now needs to work on new machine.
I have installed the same Python version 3.6.5.
First issue was that when I run the code, it can not find a re.py library, which is in fact in Python's Lib folder. So I have added sys.path.append('C:\Python\Lib') and now it can find it.
But now I get the syntax error from that library, where I say import re, that lines throws an error regarding some line in re.py library. If I import getopt, I also get syntax error on some line.
How is that even possible? Syntax error in pythons Lib files which came with installation?
And the thing is that on machine 1 it works, same file contents, same python version. I am under impression that I have wrong in python.exe version for this version of libraries, but I have simply downloaded Windows installer and installed it.
I don't even know what to google for, does someone has any idea? I am importing re in WeblogicAuto.py on line 5.
D:\Jenkins\workspace\weblogic-full-deployment-copy\weblogic-deployment>MainAutoDeployment.py -f DEV -v 2.61.0.12
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Problem invoking WLST - Traceback (innermost last):
File "D:\Jenkins\workspace\weblogic-full-deployment-copy\weblogic-deployment\WeblogicAuto.py", line 5, in ?
File "C:\Python\Lib\re.py", line 247
b"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890")
^
SyntaxError: invalid syntax
You are using WLST (WebLogic Scripting Tool).
WLST is very specific distribution of python:
it's jython
it roughly corresponds with python 2.7
And you trying to import libs from your CPython 3.6.5 distribution.
You need to:
remove your sys.path.append that you added earlier
check python libraries in jython library path. Which could be $HOME/.jython or WLST-specific path (look in WebLogic documentation)
OK many thanks to ya all, I've found the solution, it was about Jython libraries. I will try to elaborate a bit if someone stumbles upon this issue.
What I do here is that I deploy java modules to Oracle Weblogic application server. So this answer will also help someone trying to deploy to Weblogic from python.
From the start I was avoiding to install Webloglogic software on a machine from where I do the deploy (and that is a Jenkins slave which runs these python file, simple job).
I noticed that first machine (first Jenkins slave) has Weblogic installed, but I like to keep it minimal :)
What you do need is weblogic.jar and (not sure at this moment) wlfullclient.jar which is generated on Weblogic server (google how if needed or you may already have it).
The thing is that even though I have pure python code, when you call another python code with java weblogic.WLST pythonCode.py, it will be run with jython application! And it needs its libraries in its sys path.
In jython file I've added print(sys.path) then run in on both machines (slaves). I've noticed that path is different on those machines, even though if you type it in command prompt you get the same, but different then when Jenkins runs it.
So instead of looking how to fix those paths and copy files to them, I have created folders where it expects them, and copied them from first machine (easy fix, I may look into it later).
These are the sys.path and files that were needed, present on first machine:
['D:\\Jenkins\\weblogic\\Lib', '__classpath__', 'C:/bea10/wlserver_10.3/server/lib/weblogic.jar', 'C:/bea10/wlserver_10.3/common/wlst/modules/jython-modules.jar/Lib', 'C:/bea10/wlserver_10.3/common/wlst', 'C:/bea10/wlserver_10.3/common/wlst/lib', 'C:/bea10/wlserver_10.3/common/wlst/modules', '.']
This was sys.path on second machine, so I simply copied there:
['D:\\Jenkins\\weblogic\\Lib', '__classpath__', 'D:/Jenkins/server/lib/weblogic.jar', 'D:/Jenkins/common/wlst/modules/jython-modules.jar/Lib', 'D:/Jenkins/common/wlst', 'D:/Jenkins/common/wlst/lib', 'D:/Jenkins/common/wlst/modules', '.']
Note that jython-modules.jar is a file, so /Lib should be from that file if I get how java works.
Feel free to contact me for more details.
I have downloaded the pyivi.0.08 package but experience an error when run the command import pyivi. I have also installed the NI Visa and the 488.2 package.
Is there any other package to be installed before running this command.
I am trying to communicate with a Keysight/Agilent Network analyzer through a GPIB using python scripting.
Thanks in advance.
The package pyivi.0.08 is supported on the Python package index and has a nice set of documentation here: https://pypi.python.org/pypi/pyivi/0.0.8
If the documentation doesn't get you started, please list the specific error, and mention how far you were able to work through the documentation. I'll update my answer to respond to your error message.
I'm trying to write a program that uses the scapy modules. I'm using PyDev for my development but it keeps giving me errors when I import certain parts of the Scapy module. I'm pretty sure I have my import paths in PyDev set up correctly. I've looked at some of the other questions involving "Unresolved Import" errors on here. However, none of the suggestions I saw seemed to help.
The weird thing is that it is only part of the scapy modules that don't work. So for instance PyDev doesn't complain when I do
from scapy.all import Ether, sendp
However, when I do
from scapy.all import IP, UDP
I get errors.
I thought maybe I was importing the wrong modules but when I go to the interpreter and type in the second example it gives no errors and then I can create IP packets using IP(params), which is what I'm trying to do in my program.
I installed scapy using the ubuntu repositories, but when I started having import problems I downloaded the latest version from scapy.net and used the setup script. I even copied the zip and put it in my /usr/local/lib/python2.7/site-packages folder and added it to my python path in PyDev. But nothing seems to get rid of the error.
Any suggestions on what could be causing this and how to fix it?
Have you tried adding 'scapy' to the forced builtins? See: http://pydev.org/manual_101_interpreter.html for details.
I got a chance to play some more with this. I still don't know why PyDev gives me an import error when it works fine in the interpreter, however, I did find a way around it. To import things like IP, UDP, and TCP I'm now using the following
from scapy.layers.inet import IP, TCP, UDP
For non IPv4 stuff
from scapy.all import <Module Name>
seems to work just fine.