Software configuration
Operating system: Ubuntu 16.04
ROS version: kinetic
Python version: python2.7, python3.5, python3.8
Function package and routine
Refer to “ROS robot development and practice” section 4.2.3 using turtle simulator routine turtle_ TF, execute the command:
roslaunch turtle_tf turtle_tf_demo.launch
report errors
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py", line 37, in <module>
import tf
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) Traceback (most recent call last):
File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py", line 37, in <module>
import tf
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)
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_listener.py", line 37, in <module>
import tf
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)
find by hard and thorough search
At the beginning, try the methods mentioned on the Internet, such as modifying the python version and soft link, and input on the terminal:
python --version
After getting python2.7, the running routine still reports an error, so I want to find the reason according to the error
↓
Find the error report file from the first line of the error report:
/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py
Turn on Turbo_ tf_ After editing the broadcast.py file, it is found that the first line of the file states:
#!/usr/bin/env python
Input in the terminal:
/usr/bin/env python
It shows the python version pointed by the python variable in the environment variable, which is different from the routine’s requirement of python2.7.
Problem solving: modify Python in environment variables
//Modify the priority of different python versions
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
//Manual priority selection
sudo update-alternatives --config python
*Remember to input “/ usr/bin/env Python” in the terminal to check whether the modification is successful.
After the modification is successful, run the routine again to see two little turtles. The little turtle at the bottom moves towards the little turtle at the center.
Read More:
- How to Fix tensorflow2.0 tf.placeholder Error
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- Python: How to Solve multiprocessing module Error in Windows
- How to Solve no module fcntl Error in Windows
- Python: How to Solve mysqlclient Install Error in Mac
- How to Solve Python ImportError: cannot import name UnrewindableBodyError
- How to Solve Pytorch DataLoader Loading Error: UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe5 in position 1023
- How to Solve Error: RuntimeError CUDA out of memory
- How to Solve Pychart configuration import torch error
- How to Solve pyqt5 imports module Error
- How to Solve paddleOCR recognition of curved text Error
- How to Solve PyInstaller Package Error: ModuleNotFoundError: No module named ‘xxxx‘
- How to Solve Error “ImportError: cannot import name imsave“
- How to Solve M1 chip import numpy Error
- Python: How to Solve error While importing windpy
- PyCharm: How to Solve Tensorflow_datasets Import Error
- How to Solve Error handling after upgrade pip of Anaconda
- How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)
- How to Solve PIP3 error After upgrading pip3 install –upgrade pip
- Tensorflow: Common Usage of tf.get_variable_scope()