ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
6

How to install and launch Python node inside a virtualenv?

asked 2016-03-07 19:41:52 -0600

Cerin gravatar image

I'm writing a Python ROS node, and all the documentation seems to assume I've installed all my package dependencies into the global site-packages. Best practices in the Python world is to use a virtualenv. However, I can't find anything in the tutorials that mentions this. When launching my node, is it enough to source my virtualenv, or is there some special configuration I need to do first?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
8

answered 2016-03-09 09:55:46 -0600

sloretz gravatar image

If the python code was written by you and is part of one of your own ROS package then sourcing the ros workspace's devel/setup.bash will make all the python libraries available for import just like virtualenv does. These links should give enough info to set up a ros package to do so.

http://docs.ros.org/jade/api/catkin/h...

https://github.com/ros-infrastructure...

AFAIK there isn't any special configuration needed to use a virtualenv when developing Python nodes. I sourced devel/setup.bash in my ros workspace first, then sourced bin/activate in a virtualenv and found I was able to import modules from both the ros packages and the libraries installed in just the virtualenv.

edit flag offensive delete link more

Comments

1

Thanks. I've verified this also.

Cerin gravatar image Cerin  ( 2016-03-09 11:50:19 -0600 )edit
2

answered 2016-12-03 12:56:14 -0600

newbiep gravatar image

It doesn't matter if you have your own ROS package or whatever, virtualenv is a tool to isolate python environments. THe first time I was lost, but I found a guide to learn more about virtualenvs.

Hope it helps!!

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2016-03-07 19:41:52 -0600

Seen: 12,385 times

Last updated: Mar 09 '16