mac@ubuntu:~$ roscore
Traceback (most recent call last):
File "/opt/ros/kinetic/bin/roscore", line 36, in <module>
from rosmaster.master_api import NUM_WORKERS
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmaster/__init__.py", line 35, in <module>
from .main import rosmaster_main
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmaster/main.py", line 43, in <module>
import rosmaster.master
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmaster/master.py", line 47, in <module>
import rosmaster.master_api
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmaster/master_api.py", line 72, in <module>
from rosmaster.util import xmlrpcapi
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmaster/util.py", line 48, in <module>
from defusedxml.xmlrpc import monkey_patch
ImportError: No module named 'defusedxml'
##后续操作
mac@ubuntu:~$ ls -n /usr/bin/python
lrwxrwxrwx 1 0 0 24 Mar 7 16:20 /usr/bin/python -> /etc/alternatives/python
mac@ubuntu:~$ sudo ln -s /usr/bin/python2 /usr/bin/python
ln: failed to create symbolic link '/usr/bin/python': File exists
mac@ubuntu:~$
##后续操作
mac@ubuntu:/usr/bin$ python2 --version
Python 2.7.12
mac@ubuntu:/usr/bin$ python --version
mac@ubuntu:/usr/bin$ python2 --version
Python 2.7.12
mac@ubuntu:/usr/bin$ python --version
Python 3.5.2
mac@ubuntu:/usr/bin$ sudo rm -rf /usr/bin/python
mac@ubuntu:/usr/bin$ sudo ln -s /usr/bin/python2 /usr/bin/python
原因
引起这一错误的原因是无法找到/usr/bin/python这一链接,或者该链接并不是指向Python2。
ls -n /usr/bin/python
可以查看其指向,若是无该链接,则
sudo ln -s /usr/bin/python2 /usr/bin/python
若是有该链接,但是指向了Python3,则先
sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2 /usr/bin/python
sudo rm -rf /usr/bin/python
evo中是
sudo ln -s /usr/bin/python3.5 /usr/bin/python
sudo rm -rf /usr/bin/python