ModuleNotFoundError: No module named 'netifaces'
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
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?
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
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
another error i get when running
rosdep install netifaces
isERROR: 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
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 have you also built your own Python 2? If not it's probably worth opening a second question.
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 ofwhich python2
, and the result ofpython2 -c 'import netifaces
This is because the rosdep key is named
python-netifaces
, matching the apt package name rather than the python import name.