0
$\begingroup$

Rosanswers logo

I have installed googlemaps, numpy and polyline using pip install command on ubuntu 16.04. As I run the code using sudo python code.py, it works. But, When I use rospy in code and run it as rosrun package code.py the code doesn't work. It shows problem in connecting googlemap API. I want to include these python packages(googlemaps..) on ROS so that the code works on ROS. How to do it?


Originally posted by amar on ROS Answers with karma: 16 on 2017-06-21

Post score: 0


Original comments

Comment by ufr3c_tjc on 2017-06-21:
Why do you run it with sudo? Do you get errors running code.py without sudo?

Comment by amar on 2017-06-22:
to run a pyhton script i use sudo. Without sudo i get errors as ros can't find the pyhton packages which i installed using pip. I just want to know how to use googlemaps , numpy and polyline on ROS. I want to know how to run the code with these modules using rosrun.

Comment by gvdhoorn on 2017-06-22:
Using sudo is almost never necessary, and should certainly not be required for starting regular Python scripts that load a few libraries. Did you use a virtualenv to install your libraries? Can you tell us the output of:

$ python
...
>>> import numpy <enter>

Comment by gvdhoorn on 2017-06-22:
And perhaps also: which python?

Comment by amar on 2017-06-22:
python- 2.7.12 . I installed those packages using pip install command. I want to run the python script using rosrun so that i can publish data. But when i use rosrun the code doesn't work. using sudo to run the code is not a concern

Comment by gvdhoorn on 2017-06-22:\

using sudo to run the code is not a concern

it is a concern, as it should not be necessary and seems to point to 'larger' problems with your setup / configuration.

pip-installed modules should be usable under any account. And should also work 'with ROS'.

Comment by gvdhoorn on 2017-06-22:
Can you tell us what the output is of echo $PYTHONPATH? Both before and after you have sourced setup.bash?

Comment by gvdhoorn on 2017-06-22:
Also: please edit your original question and include the errors that you encounter when trying to run your node using rosrun. Use the Preformatted Text button (the one with 101010 on it) to format everything properly.

Comment by amar on 2017-06-22:
echo $PYTHONPATH results /home/pi/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Thanks!! I solved the problem. I tried again by creating a catkin workspace and it works using rosrun.


Originally posted by amar with karma: 16 on 2017-06-22

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by gvdhoorn on 2017-06-22:
So it was a configuration error.

Good to hear that you resolved it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.