Ask Your Question
0

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

asked 2018-06-18 10:35:37 -0500

jack gravatar image

updated 2018-06-18 11:14:16 -0500

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 rr_cell_data_monitor_node 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/...

[2] http://docs.ros.org/independent/api/r...

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

edit retag flag offensive close merge delete

Comments

2

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?

gvdhoorn gravatar imagegvdhoorn ( 2018-06-18 10:49:59 -0500 )edit

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

jack gravatar imagejack ( 2018-06-18 10:57:15 -0500 )edit
1

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.

gvdhoorn gravatar imagegvdhoorn ( 2018-06-18 11:02:15 -0500 )edit
1

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).

gvdhoorn gravatar imagegvdhoorn ( 2018-06-18 11:04:30 -0500 )edit

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 ..

gvdhoorn gravatar imagegvdhoorn ( 2018-06-18 11:08:32 -0500 )edit

.. 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.

gvdhoorn gravatar imagegvdhoorn ( 2018-06-18 11:08:57 -0500 )edit

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!

jack gravatar imagejack ( 2018-06-18 11:16:24 -0500 )edit

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_

jack gravatar imagejack ( 2018-06-18 11:24:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-06-18 11:21:11 -0500

jack gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-06-18 10:35:37 -0500

Seen: 731 times

Last updated: Jun 18 '18