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) )
Related
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.
Below is my latex_template.py file
min_latex = (r"\documentclass{article}"
r"\begin{document}"
r"Hello, world!"
r"\end{document}")
from latex import build_pdf
# this builds a pdf-file inside a temporary directory
pdf = build_pdf(min_latex)
# look at the first few bytes of the header
print bytes(pdf)[:10]
When I try to run this file I get the following error:
python latex_template.py
Traceback (most recent call last):
File "latex_template.py", line 9, in <module>
pdf = build_pdf(min_latex)
File "/home/psycane/test/venv/local/lib/python2.7/site-packages/latex/build.py", line 205, in build_pdf
raise RuntimeError('No available builder could be instantiated. '
RuntimeError: No available builder could be instantiated. Please make sure LaTeX is installed.
Please help!
It seems like your're missiing the latex binaries.
On linux machines it's calles texlive --> More infos
For example Ubuntu:
sudo apt-get install texlive
For OSX you can install MacTex
If your system is ubuntu or debian, the solution is below.
sudo apt-get install latexmk
If your system is other linux distribution, you need to find solution to install "latexmk" by yourself.
You must haven't installed "latexmk" judged by "bool(which(self.latexmk))" in the following source code.You can test it in cmd tools with the cmd "which latexmk"
def build_pdf(source, texinputs=[]):
"""Builds a LaTeX source to PDF.
Will automatically instantiate an available builder (or raise a
:class:`exceptions.RuntimeError` if none are available) and build the
supplied source with it.
Parameters are passed on to the builder's
:meth:`~latex.build.LatexBuilder.build_pdf` function.
"""
for bld_cls in PREFERRED_BUILDERS:
builder = bld_cls()
if not builder.is_available():
continue
return builder.build_pdf(source, texinputs)
else:
raise RuntimeError('No available builder could be instantiated. '
'Please make sure LaTeX is installed.')
def is_available(self):
return bool(which(self.pdflatex)) and bool(which(self.latexmk))
The github link is https://github.com/mbr/latex/blob/master/latex/build.py.
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 install imgseek- the server version (http://www.imgseek.net/) to do image analysis.I am able to install all the dependencies successfully using:
sudo port install swig
sudo port install swig-python
sudo easy_install twisted
sudo port install imagemagick
sudo easy_install epydoc
Then I download isk-daemon from the downloads(isk-daemon-0.9.3.tar.gz) and build and install it. Everything runs succesfully.
But when I run iskdaemon.py from the command prompt, i get the following error:
sk-daemon : WARNING | no config file (isk-daemon.conf) found. Looked at local dir, home user dir and /etc/iskdaemon. Using defaults for everything.
root : ERROR Unable to load the C++ extension "_imgdb.so(pyd)" module.
root : ERROR See http://www.imgseek.net/isk-daemon/documents-1/compiling
Traceback (most recent call last):
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/ImageDB.py", line 35, in
import imgdb
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 28, in
_imgdb = swig_import_helper()
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 20, in swig_import_helper
import _imgdb
ImportError: dlopen(/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so, 2): Symbol not found: __ZNSs4_Rep20_S_empty_rep_storageE
Referenced from: /Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so
Expected in: dynamic lookup
Please help!
I had the same problem when I was trying to install iskdaemon on my Mac (osx yosemite).
The problem in my case was that when I was building it, the c++ compiler threw two errors on using min function in imgdb.cpp
The error was because the types of the variables in the min function were not the same. Consequently the build failed and the imgdb module wasn't produced.
I fixed it by adding a simple typecast to the variables passed to the min function:
I changed: min(sz, numres) to min(sz, (long int)numres) on line 1003,
and min((V.size()/2), numres) to min((int)(V.size()/2), numres) on line 1327
I built again and it is working now.
Check if you get any errors when you build, maybe you are facing the same issue.
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))