Ask Your Question

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

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.

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


Thanks. I've verified this also.

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

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

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

Your Answer

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

Add Answer

Question Tools



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

Seen: 5,982 times

Last updated: Mar 09 '16