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:
- Tensorflow import Error: ImportError: libcuda.so.1: cannot open shared object file: No such file or dire
- [How to Solve] ImportError: No module named typing
- Raspberry pie Use PCA9685() Error: [Errno 121] Remote I/O error
- OSError libespeak.so.1 error: no such file or directory [How to Solve]
- [Solved] AttributeError: module ‘logging‘ has no attribute ‘Handler‘
- AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘ [How to Solve]
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- Keras import package error: importerror: cannot import name ‘get_ config‘
- [Solved] ansible Command Error: Error -5 while decompressing data: incomplete or truncated stream
- Importerror: DLL load failed: unable to find the specified module in Python
- [Solved] mmdetection benchmark.py Error: RuntimeError: Distributed package doesn‘t have NCCL built in
- How to Solve Python ImportError: cannot import name UnrewindableBodyError
- [Solved] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclie
- [Solved] Python Project Error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application
- [Solved] Pdfplumber Read PDF Sheet Error: AttributeError: function/symbol ‘ARC4_stream_init‘ not found in library
- [Solved] Add-apt-repository Command Error: AttributeError: ‘Thread‘ object has no attribute ‘isAlive‘
- [Solved] Torch Build Module Error: NotImplementedError
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- An introduction to sys modules in Python and how packages are imported and used
- Python Fatal error: Py_Initialize: unable to load the file system codec