getting nfcpy working in basic form

Asked by ian@iwjohnston.com

I did a bit of work back earlier in 2016 with nfcpy on raspberry pi. It worked with by basic testing using tagtool.py. I have returned to raspberry pi (3) and reloaded nfcpy once more. However at the very start python is complaining when I try to test:

 pi@raspberrypi:~ $ python -m nfc
/usr/bin/python: No module named nfc.__main__; 'nfc' is a package and cannot be directly executed

If I skip this step the Sony card reader appears to be recognised the first time around. (SONY RC-S380) but on the second try I get:

>>> import nfc
>>> clf = nfc.ContactlessFrontend('usb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/nfc/clf/__init__.py", line 72, in __init__
    raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
IOError: [Errno 19] No such device
>>>

Also I notice that sometimes I have to use SUDO which I do not want to use. I guess this is a permissions thing but how do I get around it?

It may be my newbie skills are the cause...

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
Stephen Tiedemann
Solved:
Last query:
Last reply:
Revision history for this message
Best Stephen Tiedemann (stephen-tiedemann) said :
#1

You were probably looking at the documentation for the "latest" version (which belongs to the "master" branch on GitHub) but have installed the latest "stable" version 0.11.1 (or any earlier). The "python -m nfc" thing only works with master (or v0.12 when it's out). You can either switch documentation (at bottom of left sidebar or just go to http://nfcpy.readthedocs.io/en/stable-0.11/index.html) and use "examples/tagtool.py --defive <full-device-path>", or grab the master branch from GitHub (git clone https://github.com/nfcpy/nfcpy.git).

Revision history for this message
ian@iwjohnston.com (ian-5) said :
#2

Thx Stephen. Got things working by using the "switch documentation and use of examples/tagtool.py" choice. BTW is it best to stick to the latest "stable" version 0.11.1 for developing an NFC tag application?

Regards,
Ian

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#3

The advantage of a release version is that it gives you a stable environment for a potential deployment. And it can be installed with pip.

On the master branch you might experience API changes and suffer from mistakes. But generally it's supposed to be just working - it's not a development branch.

It probably depends on whether you're heading for a "product" or an "experiment". For the latter you might just use the latest version but for a "product" you should really stick to a stable release.