from pyrrd.rrd import DataSource, RRA, RRD
filename = 'test.rrd'
dataSources = []
roundRobinArchives = []
dataSource = DataSource(dsName='speed', dsType='COUNTER', heartbeat=600)
dataSources.append(dataSource)
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=1, rows=24))
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=6, rows=10))
myRRD = RRD(filename, ds=dataSources, rra=roundRobinArchives, start=920804400)
myRRD.create()
Executing the above code, gives this error
rrdtool create test.rrd --start 920804400 --step 300 DS:speed:COUNTER:600:U:U RRA:AVERAGE:0.5:1:24 RRA:AVERAGE:0.5:6:10
Traceback (most recent call last):
File "test.py", line 10, in <module>
myRRD.create()
File "build/bdist.linux-x86_64/egg/pyrrd/rrd.py", line 175, in create
File "build/bdist.linux-x86_64/egg/pyrrd/backend/external.py", line 49, in create
File "build/bdist.linux-x86_64/egg/pyrrd/backend/external.py", line 21, in _cmd
pyrrd.exceptions.ExternalCommandError: /bin/sh: 1: rrdtool: not found
I am new to rrd tool. Kindly Help me to fix this. Thanks in advance.
You've described two different ways to create rrd file: one through the python package pyrrd, and one using the command-line tool, named rrdtool.
You don't need to use both - if you want to create the file using the python script, just run it like a regular script.
When you download pyrrd with apt-get (on ubuntu), it downloads also the cmd tool, while if you download it using pip, it downloads only the python package.
Since using your code on my environment work (no special PYTHONPATH configuration), I assume you have some installation problem, try re-installing, or installing the cmd tool separately.
Related
Hello there fellow Devs :)
I want to listen for the information given by the MMA8452 acceleration sensor with python.
To do this i want to use the libiio package for python.
To install it I manually built it following the instructions given in this guide
It seemed to be installed fine, cuz I have no Problem importing the Package because it is located in my site-packages folder.
However if I want to do the initial step of creating a context with the "iio.context()"-function, I get this error:
Traceback (most recent call last):
File "./bindings/python/examples/iio_info.py", line 89, in <module>
main()
File "./bindings/python/examples/iio_info.py", line 34, in main
ctx = iio.Context(uri)
File "/usr/local/lib/python2.7/dist-packages/iio.py", line 730, in __init__
self._context = _new_default()
File "/usr/local/lib/python2.7/dist-packages/iio.py", line 33, in _checkNull
raise OSError(err, _strerror(err))
OSError: [Errno 2] No such file or directory
Can someone help me get the iio package working?
For my hardware:
I use the Raspberry Pi3 model B, with Raspberian-stretch-lite v4.9
Thanks in advance,
Holger
You should just need to install the libiio python package to be able to use it. In libiio/bindings/python/ run:
$sudo python setup.py install
Here's a little sample script (Python 2.7) that works on my system, since I have an mcp3204 adc with an iio driver loaded. I used 'apt install python-libiio' to install the python bindings for libiio.
#! /usr/bin/python
import time, iio
ctx = iio.LocalContext()
ctrl = ctx.find_device('mcp3204')
voltages = ['voltage0', 'voltage1', 'voltage2', 'voltage3']
for id in voltages:
chan = ctrl.find_channel(id)
print("{0}: {1}".format( chan.id, chan.attrs['raw'].value) )
I'm trying to run a Python script that involves ARP sniffing and is apparently dependent on the Scapy library being present. I have absolutely no idea what I'm doing but I'm reasonably good at Googling, following directions, and copying/pasting. I have it up and running on my Mac, but I'm stuck on what I hope is the last hurdle in getting Scapy working on my Windows computer (which is ultimately the one that needs to be running this script).
I followed all of the instructions at http://www.secdev.org/projects/scapy/doc/installation.html#windows, except that I chose Python 2.7 and used the newer 2.7-compatible versions of everything listed there. I used “python setup.py install” (successfully, as best I could tell) on all installs except Pypcap and Libdnet, which I installed via the Exe as an Administrator as instructed.
Unfortunately, when I type "scapy" into the command prompt to test if it works, I get the following information & error message:
C:\scapy-2.3.1>scapy
INFO: Can't import python gnuplot wrapper . Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
Traceback (most recent call last):
File "C:\Python27\Scripts\\scapy", line 25, in <module>
interact()
File "C:\Python27\lib\site-packages\scapy\main.py", line 278, in interact
scapy_builtins = __import__("all",globals(),locals(),".").__dict__
File "C:\Python27\lib\site-packages\scapy\all.py", line 16, in <module>
from arch import *
File "C:\Python27\lib\site-packages\scapy\arch\__init__.py", line 79, in <module>
from windows import *
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 214, in <module>
ifaces.load_from_dnet()
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 173, in load_from_dnet
self.data[i["name"]] = NetworkInterface(i)
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 93, in __init__
self.update(dnetdict)
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 107, in update
self._update_pcapdata()
File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 118, in _update_pcapdata
win_name = pcapdnet.pcap.ex_name(guess)
AttributeError: 'module' object has no attribute 'ex_name'
Can anyone help me out? If you need more information please let me know.
I am running Windows 10.
Thanks in advance,
- Ethan
I had same problem.
To solve it, i downloaded dnet-1.12.win32-py2.7.exe
and pcap-1.1.win32-py2.7.exe.
You might want to try with Scapy's current development version (from the Github repository). Support for Windows has been updated recently and should work without the need of Libdnet.
If that's not the case, you should probably open an issue.
Try it with scapy3k. Install python3 (e.g. I use Anaconda 3.5), and WinPcap driver. You do not need dnet or pypcap. Install using pip install scapy-python3 or from http://github.com/phaethon/scapy
I am trying to use Bloomberg python API. I need to set BLPAPI_ROOT environment variable for this. I added,
export BLPAPI_ROOT="/home/user/Downloads/blpapi_cpp_3.6.3.1"
export PATH=$PATH:$BLPAPI_ROOT
to my .bashrc file and ran source .bashrc.
Now, when I open python shell and do,
print os.environ['BLPAPI_ROOT']
it gives me correct output. But when the same this runs inside the setup.py provided, it throws a
Traceback (most recent call last):
File "setup.py", line 27, in <module>
blpapiRoot = os.environ['BLPAPI_ROOT']
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'BLPAPI_ROOT'
What am I missing here ?
System :
Ubuntu 12.04
Python 2.7
I would try using it the following way:
import os
try:
os.environ['BLPAPI_ROOT'] = "/home/user/Downloads/blpapi_cpp_3.6.3.1"
except EnvironmentError:
sys.exit(1)
This is quite old, but for anyone searching, you can get around this by setting sudo to keep the environmental variable BLPAPI_ROOT, a la keep environmental variables using sudo.
sudo visudo
Then add:
Defaults env_keep +="BLPAPI_ROOT"
You can now run:
sudo python setup.py install
and it should work just fine.
I have a problem with pysdl2. I'm trying to launch examples from site-packages\sdl2\examples and see this error:
c:\Python33\Lib\site-packages\sdl2\examples>python draw.py
Traceback (most recent call last):
File "draw.py", line 10, in <module>
import sdl2.ext as sdl2ext
File "C:\Python33\lib\site-packages\sdl2\ext\__init__.py", line 14, in <module>
from .common import *
File "C:\Python33\lib\site-packages\sdl2\ext\common.py", line 8, in <module>
from .. import sdlttf
File "C:\Python33\lib\site-packages\sdl2\sdlttf.py", line 40, in <module>
os.getenv("PYSDL2_DLL_PATH"))
File "C:\Python33\lib\site-packages\sdl2\dll.py", line 51, in __init__
raise RuntimeError("could not find any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2_ttf
But files which don't use sdl2_ttf (such as sdl2hello.py) work correctly and without errors. I have no idea how to solve it.
Additional info: WinXP SP3 32bit
This error seems to be the result of the script not finding the SDL2_ttf package.
Following the instructions of the PySDL2 manual, you must have set a PYSDL2_DLL_PATH like so:
# Win32 platforms
set PYSDL2_DLL_PATH=C:\path\to\fancy_project\third_party
# Unix/Posix-alike environments - bourne shells
export PYSDL2_DLL_PATH=/path/to/fancy_project/third_party
# Unix/Posix-alike environments - C shells
setenv PYSDL2_DLL_PATH /path/to/fancy_project/third_party
so you just have to get the SDL2_ttf package here: http://www.libsdl.org/projects/SDL_ttf/ and download the runtime library corresponding to your system (http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12-win32-x86.zip) and add it in the same folder where SDL2.dll is. Check out at C:\your-python-directory\DLLs
It's the same with SDL_image, SDL_mixer, SDL_net and SDL_gfx (on another website though for this last one).
Hope this helps !
Got the same issue
brew install sdl2
Solved my problem on OSX
i am trying to run one of the example scripts for nxt py library using pyusb. whenever i try to run the examples i get the following error:
USB module unavailable, not searching there
Bluetooth module unavailable, not searching there
Traceback (most recent call last):
File "C:\Documents and Settings\*\Desktop\nxt-python-2.2.1\examples\mary.py", line
15, in <module>
b = nxt.locator.find_one_brick()
File "C:\Python27\lib\site-packages\nxt\locator.py", line 112, in find_one_brick
for s in find_bricks(host, name, silent, method):
File "C:\Python27\lib\site-packages\nxt\locator.py", line 80, in find_bricks
raise NoBackendError("No selected backends are available! Did you install the comm
modules?")
NoBackendError: No selected backends are available! Did you install the comm modules?
i have no idea how to fix this and i was wondering if there was any other way than just switching to bluetooth?
USB and Bluetooth are unavailable. You need to install python modules to be able to run examples.
Here is installation guide,
choose your operating system.
For me (mac os x) works only fantomusb. Also I needed to set attributes for brick locator to find it trought fantomusb.
b = nxt.locator.find_one_brick(name="NXT", strict=True, method=nxt.locator.Method(bluetooth=False, fantomusb=True, fantombt=False, usb=False))