0
$\begingroup$

Rosanswers logo

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?


Originally posted by Cerin on ROS Answers with karma: 940 on 2016-03-07

Post score: 6

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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/html/howto/format2/installing_python.html

https://github.com/ros-infrastructure/rep/blob/master/rep-0008.rst

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.


Originally posted by sloretz with karma: 3061 on 2016-03-09

This answer was ACCEPTED on the original site

Post score: 8


Original comments

Comment by Cerin on 2016-03-09:
Thanks. I've verified this also.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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!!


Originally posted by newbiep with karma: 21 on 2016-12-03

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

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