Whenever I have the virtual environment for Python activate and the script uses modules to interact with the robot, I get this message:
(py3venv) user:~/catkin_ws/src/robot_control$ python test_if.py
Traceback (most recent call last):
File "test_if.py", line 1, in <module>
from robot_control_class import RobotControl
File "/home/simulations/public_sim_ws/src/all/ros_basics_examples/python_course_class/robot_control_class.py", line 7, in <module>
from tf.transformations import euler_from_quaternion, quaternion_from_euler
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
from tf2_py import *
File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
from ._tf2 import *
ImportError: dynamic module does not define module export function (PyInit__tf2)
If I do not source the virtual environment, the code work with the robot, but I always get this message
at the beginning :
the rosdep view is empty: call ‘sudo rosdep init’ and ‘rosdep update’
Is it a known problem and is there a way to fix it?
To use ROS in python3, you have to custom compile it with python3 and change the source code of some packages like tf2. What exactly are you trying to accomplish?
It happens to me as well.
The virtual environment of the course seems to be wrongly configured as trying to run the script invokes python 2.7 (when the course is titled Python 3 for robotics).