Ask Your Question
0

Conflict anaconda vs ROS, catking_pkg not found

asked 2017-03-13 12:30:56 -0600

Kailegh gravatar image

Hi, I recently installed anaconda in my computer, and now I cant catkin build or catkin_make_isolated (tried them in different ws) I use ubuntu 16.04 and ros kinetic

When running catkin build i get this;

Errors     << catkin_tools_prebuild:cmake /home/daniel/catkin_ws/logs/catkin_tools_prebuild/build.cmake.000.log          
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/home/daniel/anaconda3/bin/python
  "/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/kinetic/share/catkin/cmake/../package.xml"
  "/home/daniel/catkin_ws/build/catkin_tools_prebuild/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake:63 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:151 (_catkin_package_xml)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)

When running catkin_make_isolated:

-- Using CATKIN_DEVEL_PREFIX: /home/daniel/catkin_ws2/devel_isolated/cartographer_ros_msgs
-- Using CMAKE_PREFIX_PATH: /home/daniel/catkin_ws2/install_isolated;/home/daniel/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/daniel/catkin_ws/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /home/daniel/anaconda3/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/daniel/catkin_ws2/build_isolated/cartographer_ros_msgs/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /home/daniel/anaconda3/bin/nosetests
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/home/daniel/anaconda3/bin/python
  "/opt/ros/kinetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/kinetic/share/catkin/cmake/../package.xml"
  "/home/daniel/catkin_ws2/build_isolated/cartographer_ros_msgs/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkin_package_xml.cmake:63 (safe_execute_process)
  /opt/ros/kinetic/share/catkin/cmake/all.cmake:151 (_catkin_package_xml)
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:27 (find_package)

The problem I think it is that it is getting anaconda python path. I have tried: sudo apt-get install --reinstall python-rospkg python-rosdep python-catkin-pkg python-rosinstall python-vcstools I will list you some commands I have seen in other questions, that might be useful:

echo $PYTHONPATH 
/home/daniel/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
dpkg -L python-catkin-pkg
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-catkin-pkg
/usr/share/doc/python-catkin-pkg/changelog.Debian.gz
/usr/bin
/usr/bin/catkin_generate_changelog
/usr/bin/catkin_tag_changelog
/usr/bin/catkin_create_pkg
/usr/bin/catkin_test_changelog
/usr/bin/catkin_find_pkg
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/catkin_pkg-0.3.1.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg-0.3.1.egg-info/top_level.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.3.1.egg-info/dependency_links.txt
/usr ...
(more)
edit retag flag offensive close merge delete

Comments

2

Any help here? Thanks a lot !!

easiest would be to remove anaconda3/bin from your PATH.

gvdhoorn gravatar imagegvdhoorn ( 2017-03-13 12:57:15 -0600 )edit

Here's some help from the IDE entry in the wiki

jayess gravatar imagejayess ( 2018-01-09 10:30:01 -0600 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2017-03-13 12:57:01 -0600

gavran gravatar image

From the output of which python, it seems that your default python is anaconda python. Also, since your anaconda python is python3, it would be better to use ROS with another version (some python2 version).

I suggest you to use virtualenv (or virtualenvwrapper) and that way control which python you're using explicitly. Another solution could be modifying your PATH variable (I would guess that now /home/daniel/anaconda3/bin comes before /usr/bin, which is a default python location)

edit flag offensive delete link more

Comments

where can i modify the PATH variable? do I have to change it each time I want to use python3?

Kailegh gravatar imageKailegh ( 2017-03-13 15:19:45 -0600 )edit

so, the most elegant way would be working with virtualenvwrapper. That would enable you tho change between different versions easily.

gavran gravatar imagegavran ( 2017-03-14 02:46:39 -0600 )edit

If not, check your ~/.bashrc file. There should be a line that says sth like: export PATH=/home/daniel/anaconda3/bin:$PATH. remove this anaconda part and then - when you want to use anaconda, write explicitly /home/daniel/anaconda3/bin/python. don't forget to reopen terminal afterwards

gavran gravatar imagegavran ( 2017-03-14 02:48:10 -0600 )edit

... for the changes to take place (alternatively, run source ~/.bashrc

gavran gravatar imagegavran ( 2017-03-14 02:55:53 -0600 )edit
2

answered 2018-01-09 05:07:32 -0600

StefanFabian gravatar image

updated 2018-10-11 15:47:43 -0600

Gavran already explained the problem very well.

Here's just another way to solve the issue.
The easiest solutions like using the full path, exporting the path every time it's needed or creating a second user account for Anaconda aren't really convenient which is why I wrote this little script:

https://gist.github.com/StefanFabian/...

What it does
It basically scans the Anaconda binary folder and for each executable that isn't present on the system already, it creates an alias. Now, when you execute the command e.g. anaconda-navigator, it adds Anaconda to PATH, executes anaconda-navigator (which is now in PATH) and after anaconda-navigator terminated, it removes Anaconda from PATH again.
For more information and how to use it check the top of the script and the comment on GitHub below the script.

Disclaimer
I'm not very good at bash, so, if someone with more experience could take a look at the script, that'd be great.
For now view this script as beta, it works for me but it needs to be tested by more people.
I've tested it on Ubuntu 16.04 with ROS Kinetic but in theory it should work on any bash system.
Don't know about zsh, etc. though.

Here's a copy of the script at the time of writing for the unlikely event that the link goes dead

Update 1: The script now removes ROS from the PATH to prevent issues with ROS python stuff that is incompatible with the Anaconda environment python version. To make this functionality as general as possible, the python path is backed up when the script is sourced, therefore, the script has to be source before any ROS setup bash is sourced.

### This script wraps all executables in the anaconda bin folder so that they can be used without adding Anaconda
### to the path which would break some functionality of ROS (Robot Operating System)
###
### The commands e.g. jupyter notebook will cause the script to add anaconda to the path, start jupyter notebook
### and after jupyter notebook terminated remove anaconda from the path again
###
### Notable commands:
### * release-the-snake       Adds conda to the path and removes all aliases defined by this script
###                           Conda will stay in the PATH until the end of the session (terminal is closed) or
###                           until "cage-the-snake" is called
### * cage-the-snake          Removes conda from the path and redefines all aliases for anaconda executables
### * source activate [env]   Works just like with anaconda in the PATH, will activate the environment or (root) and
###                           Anaconda will stay in the PATH for the remaining session or until "source deactivate" is run
### * source deactivate       Deactivates the environment and if Anaconda wasn't released manually using release-the-snake
###                           Anaconda will be removed from the PATH again.

if [ -z ${_ROS_CONDA_ADDED+x} ]
then
  _ROS_CONDA_PATH=~/anaconda3/bin
  _ROS_CONDA_ADDED=0
  _ROS_CONDA_ALIASES=''
  _ROS_CONDA_RELEASED_MANUALLY=0
  _ROS_CONDA_PYTHONPATH_WITHOUT_ROS=$PYTHONPATH
fi

function _ROS_CONDA_addAliases {
  if [[ $_ROS_CONDA_ALIASES != '' ]]
  then
    echo "ROS Conda Wrapper: Error! Aliases already defined!"
    _ROS_CONDA_removeAliases
  fi

  for file in $_ROS_CONDA_PATH/*
  do
    local name
    name=${file##*/}
    if ! [ -x "$(command -v ...
(more)
edit flag offensive delete link more
0

answered 2018-10-04 13:25:15 -0600

mavrec gravatar image

Hello, I couldn't help but ask for help myself. I have both anaconda and ros installed, I learnt that they both would be in conflict after I installed anaconda obviously..now I am wondering if I use ros with any ipython notebook, preferably jupyter, I noticed how hard this might become. I am currently installing spyder from the package installer as an advice from my professor has used the ipython with ros onfront of us. I am wondering if there's better practice or advises basically..

Cheers!

edit flag offensive delete link more
0

answered 2020-01-17 07:51:05 -0600

rickstaa gravatar image

updated 2020-01-17 07:51:30 -0600

Based on the answers of @gavran and @StefanFabian of I created an easy to install bash wrapper that solves the problems described above. This wrapper can be found on https://github.com/rickstaa/.ros_conda_wrapper.

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

3 followers

Stats

Asked: 2017-03-13 12:30:56 -0600

Seen: 4,920 times

Last updated: Jan 17