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

Can I create a virtual environment for Python 3?

asked 2020-07-16 10:08:41 -0500

andtarspb gravatar image

Hello, everyone!

Sorry for my question, I'm really noob in ROS.

I have made an application for object detection using python 3 and TensorFlow 2.1 on my Windows 10 laptop. Now I need to install it on the PC with Ubuntu 16.04 and python 2.7 using ROS.

Is it possible to create something like a virtual environment within ROS, where I can use python 3?

On my laptop I used Anaconda for creating virtual environments, but on that PC it seems like ROS has conflicts with Anaconda. And my application only can work with python 3

Hope, you can help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-07-17 03:26:46 -0500

Solrac3589 gravatar image

updated 2020-07-17 03:37:26 -0500

A solution could be to do a node using noetic (which supports python3) and using it with docker (separate environment) This way you should be able to work properly with a computer with ubuntu 16.04 having nodes with python3 in a quite clean way while great part of the code have the original kinetic configuration .

http://wiki.ros.org/docker/Tutorials/...

Another option could be to uninstall ROS Kinetic and install ROS Noetic directly from source

http://wiki.ros.org/Installation/Source

Nevertheless seems like noetic instructions are still not written (but I imagine it should be similar to melodic or kinetic) and I am not sure if it should appear any problem

edit flag offensive delete link more
0

answered 2020-07-17 01:17:22 -0500

Alrevan gravatar image

Hello,

ROS kinetic is not compatible with ROS 3. However I had a similar use case (using python 3 for object detection) and i managed to integrate it to my ros application by using a workaround:

I created a ROS node that handles the inputs/outputs of the application (and their conversions in ROS format). This node would open a python 3 application using the subprocess module:

subprocess.Popen("Pyhton3command".split())

Then i would use a socket in order to communicate between the two processes.

I hope this can help.

edit flag offensive delete link more

Comments

Could you give us some tips how to implement it, please?

Redhwan gravatar image Redhwan  ( 2020-07-17 03:47:49 -0500 )edit

Well there is no tricky parts so basically just following a simple socket tutorial should be enough: https://realpython.com/python-sockets/

Alrevan gravatar image Alrevan  ( 2020-07-17 03:52:57 -0500 )edit

@ Alrevan thanks.

Redhwan gravatar image Redhwan  ( 2020-07-17 03:55:49 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-16 10:08:41 -0500

Seen: 1,873 times

Last updated: Jul 17 '20