Problem
“No module named catkin_pkg.package” on catkin_make w/ Indigo
I have the problem after anaconda is installed. I get an error because of the different PYTHONPATH used by anaconda.
Solution 1: turn off anaconda
In the end of file ~/.bashrc, you will find export PATH=”/home/YOURUSRNAME/anaconda3/bin:$PATH” .
In fact the ROS should use python in /opt/ros/indigo/lib/python2.7/dist-packages. Uncomment it and source ~/.bashrc then it works.
Solution 2:
http://answers.ros.org/question/220546/catkin_make-failure-due-to-python-anaconda/
Without turning off anaconda, just run pip install catkin_pkg, it may be helpful.
Conclusion
Basically the problem happens because ROS is confused with python location due to different path of python used by anaconda.
Here are some reference that instructs us how to navigation the specified python.
When the system cannot position python
installed python 3.5 thenI get this error: -bash: /usr/bin/python: No such file or directory
http://stackoverflow.com/questions/15236832/how-do-i-reinstall-a-directory-in-usr-bin-python
1 sudo rm /usr/bin/python # because that's a corrupted file 2 sudo ln -s /usr/bin/python2.7 /usr/bin/python
When you need to change the default version of python
https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
Change python version system-wide
To change python version system-wide we can use
update-alternatives
command. Logged in as a root user, first list all available python alternatives:# update-alternatives --list python update-alternatives: error: no alternatives for pythonThe above error message means that no python alternatives has been recognized by
update-alternatives
command. For this reason we need to update our alternatives table and include bothpython2.7
andpython3.4
:# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode # update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2 update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
When you cannot do catkin_make with the error “No module named rospkg”
http://answers.ros.org/question/39657/importerror-no-module-named-rospkg/
The reason this error occurs is because Python packages in /opt are added to PYTHONPATH environment variable BUT for ones in /usr, path does not exist in PYTHONPATH variable. The python-rospkg gets installed in /usr by default. So you just need followingline in .bashrc to fix this:
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages