ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ModuleNotFoundError: No module named 'netifaces'

asked 2020-03-05 03:20:52 -0500

planebula gravatar image

updated 2020-03-06 23:19:23 -0500

Error occurs when I run roscore

I installed python 2.7 manually.

praneeth@praneeth-Lenovo-Legion-Y540-15IRH-PG0:~/catkin_ws/src$ roscore
... logging to /home/praneeth/.ros/log/f4804f00-22ff-11ea-bce8-907841bf4730/roslaunch-praneeth-Lenovo-Legion-Y540-15IRH-PG0-5603.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://praneeth-Lenovo-Legion-Y540-15IRH-PG0:40321/
ros_comm version 1.14.3


PARAMETERS

/rosdistro: melodic
/rosversion: 1.14.3
NODES

Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/init.py", line 322, in main
p.start()
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/parent.py", line 288, in start
self.runner.launch()
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/launch.py", line 662, in launch
self._setup()
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/launch.py", line 637, in _setup
launched = self._launch_master()
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/launch.py", line 400, in _launch_master
validate_master_launch(m, self.is_core, self.is_rostest)
File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/launch.py", line 83, in validate_master_launch
if not rosgraph.network.is_local_address(m.get_host()):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosgraph/network.py", line 175, in is_local_address
local_addresses = ['localhost'] + get_local_addresses()
File "/opt/ros/melodic/lib/python2.7/dist-packages/rosgraph/network.py", line 217, in get_local_addresses
import netifaces
ModuleNotFoundError: No module named 'netifaces'

The result of which python: /usr/bin/python echo $PYTHONPATH /opt/ros/melodic/lib/python2.7/dist-packages python2 -c import netifaces: blank line

edit retag flag offensive close merge delete

Comments

More information would be helpful. What platform are you running on? If you installed Python 2 manually, did you also rebuild ROS against your Python2 installation? Did you use rosdep to install ROS's dependencies?

nuclearsandwich gravatar image nuclearsandwich  ( 2020-03-05 09:34:21 -0500 )edit

Running it on Ubuntu 18.04. Yes I rebuilt ROS after installing Python 2.7 and used rosdep to install dependencies, including netifaces. It seems roscore isn't able to find 2.7 in its path

planebula gravatar image planebula  ( 2020-03-05 15:23:05 -0500 )edit

When I run: rosdep install netifaces I get WARNING: ROS_PYTHON_VERSION is unset. Defaulting to 3 ERROR: Rosdep cannot find all equired resources to answer your query Missing resource netifaces

However, echo $ROS_PYTHON_VERSION returns 2

planebula gravatar image planebula  ( 2020-03-05 15:43:06 -0500 )edit

another error i get when running rosdep install netifaces is ERROR: Rosdep cannot find all required resources to answer your query Missing resource netifaces ROS path [0]=/opt/ros/melodic/share/ros ROS path [1]=/opt/ros/melodic/share

planebula gravatar image planebula  ( 2020-03-05 15:50:31 -0500 )edit

I hope this gets to be solved soonest as I've been battling this exact bug for about 48hrs now. What I plan to try is to install the module 'netifaces' directly to dist-packages. I'll let you know how it goes.

Irikefe gravatar image Irikefe  ( 2020-03-05 23:11:46 -0500 )edit

@Irikefe have you also built your own Python 2? If not it's probably worth opening a second question.

nuclearsandwich gravatar image nuclearsandwich  ( 2020-03-06 11:59:15 -0500 )edit

Running it on Ubuntu 18.04. Yes I rebuilt ROS after installing Python 2.7 and used rosdep to install dependencies, including netifaces. It seems roscore isn't able to find 2.7 in its path

It just occurred to me that if you built your own Python 2.7 that apt packages providing python libraries may not be being used by your python installation. Can you please update your question to include: Your current value of $PYTHONPATH, the result of which python2, and the result of python2 -c 'import netifaces

nuclearsandwich gravatar image nuclearsandwich  ( 2020-03-06 12:05:49 -0500 )edit

another error i get when running rosdep install netifaces is

This is because the rosdep key is named python-netifaces, matching the apt package name rather than the python import name.

nuclearsandwich gravatar image nuclearsandwich  ( 2020-03-06 12:06:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-03-07 09:55:47 -0500

Irikefe gravatar image

So I eventually found a fix to the issue. So after studying ROS filesystem it became apparent that the issue was due to the wrong default interpreter linking. Although python --version returned python2.7 this was only made possible in my case because I used an alias in my .bashrc profile.

To fix this you have to change the default python version using python2.7 alternative. Based on your bug response it is apparent python3 was your default interpreter which was the same in my case.

First list available alternatives update-alternatives --list python. If python2.7 isn't a part of the list and you have it installed, add it to the alternatives using update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

Finally, configure the alternatives using update-alternatives --config python and select python2.7 as the default.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-03-05 03:20:52 -0500

Seen: 12,247 times

Last updated: Mar 07 '20