melodic python3 script

asked 2018-10-11 07:50:18 -0600

Antracyt gravatar image

updated 2019-06-13 10:21:42 -0600

Evgeny gravatar image

I run ros melodic on ev3dev system. I installed ros using this tutorial. ev3dev library works only with python3. This is a part of script I am importing from subscriber node:

#!/usr/bin/env python3
from ev3dev.brickpi import *

As a result I get:

Traceback (most recent call last):
File "/home/robot/Tesla/CatkinWorkspaces/src/learn_network/scripts/RemoteControlsSubscriber.py", line 8, in <module>
from SteeringController import SteeringController
File "/home/robot/Tesla/CatkinWorkspaces/src/learn_network/scripts/SteeringController.py", line 2, in <module>
from ev3dev.brickpi import *
ImportError: No module named brickpi

EDIT: this error is 'No module named brickpi' not, No module named 'ev3dev'

Is there any way make ros to run python3 scripts? It is crucial for me, i can even rebuild ROS packages from source, as 'rivermont' mention in this issue but i don't know how do this.

edit retag flag offensive close merge delete

Comments

1

ROS can certainly run Python3 scripts. It is more likely that ev3dev is not in your path appropriately. Can you python3 -c 'import ev3dev' for me?

allenh1 gravatar imageallenh1 ( 2018-10-11 08:51:42 -0600 )edit

There is no result of this command

robot@ev3dev:~$ python3 -c 'import ev3dev'
robot@ev3dev:~$ python3 -c 'import ev3dev.brickpi'
robot@ev3dev:~$

When I run scripts through python3 command everything works fine. Problem appears when i run scripts through ros.

I edited my post, look plz

Antracyt gravatar imageAntracyt ( 2018-10-11 11:58:39 -0600 )edit

Ah, you're talking about running the node through rosrun, then? If so, that would make a lot of sense. I think a source installation is definitely the key. You can do something like a gentoo prefix install.

allenh1 gravatar imageallenh1 ( 2018-10-11 14:12:31 -0600 )edit

You can select the python version for it then by using eselect python and setting it to any python 3 version. To get ROS installed, you'll probably want to use the ROS Overlay.

allenh1 gravatar imageallenh1 ( 2018-10-11 14:13:48 -0600 )edit

Yes, I mean runing the node trough rosrun. ev3dev is debian distro, so eselect will not work.

Antracyt gravatar imageAntracyt ( 2018-10-12 04:34:36 -0600 )edit

Could you look at ros installation tutorial on ev3dev I followed (steps 1-9) and tell me what additional steps I should do? It is black magic for me.

Antracyt gravatar imageAntracyt ( 2018-10-12 04:36:04 -0600 )edit

Ok I managed this. Here is explenation https://github.com/OTL/cozmo_driver#s...

Antracyt gravatar imageAntracyt ( 2018-10-12 11:17:58 -0600 )edit