Robotics StackExchange | Archived questions

AttributeError: 'module' object has no attribute 'LiveCapture'

I'm new to ROS, Ubuntu, and the fine details of Python and I think I'm running into a file path with my ROS python package issue but I'm not sure. I'm running ROS Kinetic and Ubuntu 16.04 on a dell laptop. I'm getting an attribute error when I roslaunch my ROS node called rrcelldatamonitornode as seen below. Also please pardon my Python syntax. I may accidentally refer to something as a python package when it should be a module or library.

NODES
  /
    cell_data_monitor_node (rr_cell_data_monitor/cell_data_monitor.py)

auto-starting new master
process[master]: started with pid [32391]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 160bf0ba-7308-11e8-9b9f-f49634520fd0
process[rosout-1]: started with pid [32404]
started core service [/rosout]
process[cell_data_monitor_node-2]: started with pid [32415]
Traceback (most recent call last):
  File "/home/jack/catkin_ws/src/rr_cell_data_monitor/scripts/cell_data_monitor.py", line 210, in <module>
    cell_data_monitor_node()
  File "/home/jack/catkin_ws/src/rr_cell_data_monitor/scripts/cell_data_monitor.py", line 165, in cell_data_monitor_node
    capture = pyshark.LiveCapture(interface=interface_name, only_summaries=True, bpf_filter=filter_def)
AttributeError: 'module' object has no attribute 'LiveCapture'
[cell_data_monitor_node-2] process has died [pid 32415, exit code 1, cmd /home/jack/catkin_ws/src/rr_cell_data_monitor/scripts/cell_data_monitor.py __name:=cell_data_monitor_node __log:=/home/jack/.ros/log/160bf0ba-7308-11e8-9b9f-f49634520fd0/cell_data_monitor_node-2.log].
log file: /home/jack/.ros/log/160bf0ba-7308-11e8-9b9f-f49634520fd0/cell_data_monitor_node-2*.log

My code imports the pyshark python module to sniff for packets on the wlan0 network. I followed pyshark's github[3] for installation (pip install pyshark) and had the code and ROS package working on my laptop correctly for awhile prior to trying to add pyshark as a system dependency [1] and contributing a rosdep rule[2] for pyshark to have pyshark installed automatically. As far as I could tell, rosdep was correctly setup so I uninstalled pyshark (pip uninstall pyshark) to check if it would install and work properly. Rosdep did install pyshark but then I started getting the AttributeError. I tried for awhile to solve the problem myself and so looked into adding/changing to the $PYTHONPATH but I don't remember exactly when or what (I read a lot online but nothing seemed to fit the problem I was having). I'd be happy to provide more information as requested and any help or more information of things to look at would be greatly appreciated.

The group I'm working with is already using a forked rosdistro so I just modified that respo's yaml python.yaml file to include pyshark. This is what I added...

python-pyramid: ...stuff... python-pyshark: ubuntu: pip: packages: [pyshark]

PYTHONPATH: /home/jack/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages:/opt/ros/kinetic/share/ros/core/roslib/src:/opt/ros/kinetic/share/ros/core/roslib/src:`

[1] http://wiki.ros.org/rosdep/Tutorials/How%20to%20add%20a%20system%20dependency

[2] http://docs.ros.org/independent/api/rosdep/html/contributing_rules.html

[3] https://github.com/KimiNewt/pyshark

Asked by jack on 2018-06-18 10:35:37 UTC

Comments

Rosdep did install pyshark [..]

I cannot find any rules for pyshark in the current rosdep database. There are also no Ubuntu Xenial packages for it. Do you have locally defined rules for pyshark?

Asked by gvdhoorn on 2018-06-18 10:49:59 UTC

What counts as locally defined rules? The group I'm working with is already using a forked rosdistro so I just modified that respo's yaml python.yaml file to include pyshark. This is what I added... python-pyramid: ...stuff... python-pyshark: ubuntu: pip: packages: [pyshark

Asked by jack on 2018-06-18 10:57:15 UTC

Would have been nice to include that sort of information in your question. How else are we going to help?

Last release on PyPi: Nov 1, 2017, while the last changes to the github repository were pushed on Apr 24, 2018. It's likely the github sources contain features the PyPi release doesn't.

Asked by gvdhoorn on 2018-06-18 11:02:15 UTC

Something to check: if you start python manually (so in a terminal), does import pyshark succeed?

And what is the output following dir(pyshark)?

And it might also be good to post the command and output of your rosdep install .. invocation (after having removed pyshark again).

Asked by gvdhoorn on 2018-06-18 11:04:30 UTC

What counts as locally defined rules? The group I'm working with is already using a forked rosdistro so I just modified that respo's yaml python.yaml file

Well .. what you describe are technically not 'locally defined rules', as the fork is probably shared, but as they are not shared with the ..

Asked by gvdhoorn on 2018-06-18 11:08:32 UTC

.. ROS community I'll consider them local.

Any reason you're not considering contributing those rules?

And please add the new information to your original question. Comments are too limited for that. Use the edit button/link for that.

Asked by gvdhoorn on 2018-06-18 11:08:57 UTC

Just added that info to the original question. I haven't contributed them because I didn't know if they were correct and working.

Also I just heard back from a buddy I asked for help and I think he resolved my question. I'll add it as an answer shortly. Thank you so much for the help!

Asked by jack on 2018-06-18 11:16:24 UTC

To answer your previous questions (after putting the dummy pyshark directory back in): Does import pyshark succeed after starting python manually? No. It gives the same error. What is output of dir(pyshark)?

dir(pyshark) ['builtins', 'doc', 'file', 'name', 'package', '_path

Asked by jack on 2018-06-18 11:24:44 UTC

Answers

So the issue was I had a pyshark directory in /home/jack/catkin_ws/devel/lib/python2.7/dist-packages that only contained an init.py file. No other code was in the directory so catkin thought it found pyshark when what it really found was empty. I don't know how that pyshark directory got there but after deleting it my ROS node runs wihtout issues. I'm going to try reinstalling pyshark using rosdep to see if that directory pops up for some reason but at the moment pyshark is working.

Asked by jack on 2018-06-18 11:21:11 UTC

Comments