Ask Your Question
0

no module named rospy after anaconda install

asked 2019-01-02 08:08:11 -0600

OsManiaC gravatar image

updated 2019-01-02 08:54:57 -0600

gvdhoorn gravatar image

Hello all,

I was using ros kinetic with py scipts without problem, but then I tried installing Anaconda 3.5 and all my ROS is messed as you guess. So I uninstalled Anaconda 3.5 and installed Anaconda 2.7.

Now the problem is I cannot run py scripts, as they usually give error like ImportError: no module named 'rospy' and etc..

when I tried

which python

it shows me /usr/bin/python that I believe it is wrong

python --version

shows Python 2.7.12

I tried adding export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-package without comment but it didn't work.

where I am doing wrong? could you help me thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-02 17:15:21 -0600

Anaconda has probably installed a new version of python and more importantly updated the PYTHONPATH so that it no longer includes the path of the required ROS packages. You should be able to add the necessary path back in by adding a line to your .bashrc file.

Your PYTHONPATH envrionment variable should include a path to /opt/ros/<ros_version>/lib/python2.7/dist-packages, if it doesn't then this may be the cause of your problem. You can check this with the following command:

printenv PYTHONPATH

If you add export PYTHONPATH=$PYTHONPATH:/opt/ros/<ros_version>/lib/python2.7/dist-packages to your bashrc file and re-run it then this should hopefully fix your problem.

edit flag offensive delete link more

Comments

1

updated the PYTHONPATH so that it no longer includes the path of the required ROS packages. You should be able to add the necessary path back in by adding a line to your .bashrc file.

Note: sourceing setup.bash should setup PYTHONPATH for you. I'm not sure about Anaconda, but ..

gvdhoorn gravatar imagegvdhoorn ( 2019-01-03 03:18:33 -0600 )edit
1

.. manually changing PYTHONPATH through .bashrc should be done with care, and only if/when absolutely necessary.

Not saying it shouldn't be done in this case, just wanted to add a bit of "don't touch this willy-nilly".

gvdhoorn gravatar imagegvdhoorn ( 2019-01-03 03:19:46 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-01-02 08:08:11 -0600

Seen: 781 times

Last updated: Jan 02