进行mavros编译时,catkin build过程中提示找不到future模块


$ catkin build
--------------------------------------------------------------
Profile:                     default
Extending:          [cached] /opt/ros/melodic
Workspace:                   /home/liuyongke/catkin_ws
--------------------------------------------------------------
Build Space:        [exists] /home/liuyongke/catkin_ws/build
Devel Space:        [exists] /home/liuyongke/catkin_ws/devel
Install Space:      [unused] /home/liuyongke/catkin_ws/install
Log Space:          [exists] /home/liuyongke/catkin_ws/logs
Source Space:       [exists] /home/liuyongke/catkin_ws/src
DESTDIR:            [unused] None
--------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
--------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
--------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
--------------------------------------------------------------
Workspace configuration appears valid.
--------------------------------------------------------------
[build] Found '6' packages in 0.0 seconds.                                     
[build] Package table is up to date.                                           
Starting  >>> mavlink                                                          
Starting  >>> mavros_msgs                                                      
_______________________________________________________________________________
Errors     << mavlink:make /home/liuyongke/catkin_ws/logs/mavlink/build.make.001.log
Traceback (most recent call last):
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/tools/mavgen.py", line 16, in <module>
    from pymavlink.generator import mavgen
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ImportError: No module named future
Traceback (most recent call last):
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/tools/mavgen.py", line 16, in <module>
    from pymavlink.generator import mavgen
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ImportError: No module named future
make[2]: *** [paparazzi-v2.0-cxx-stamp] Error 1
make[1]: *** [CMakeFiles/paparazzi.xml-v2.0.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
make[2]: *** [include/v1.0/ASLUAV/ASLUAV.h] Error 1
make[1]: *** [CMakeFiles/ASLUAV.xml-v1.0.dir/all] Error 2
Traceback (most recent call last):
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/tools/mavgen.py", line 16, in <module>
    from pymavlink.generator import mavgen
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ImportError: No module named future
Traceback (most recent call last):
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/tools/mavgen.py", line 16, in <module>
    from pymavlink.generator import mavgen
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ImportError: No module named future
Traceback (most recent call last):
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/tools/mavgen.py", line 16, in <module>
    from pymavlink.generator import mavgen
  File "/home/liuyongke/catkin_ws/src/mavlink/pymavlink/generator/mavgen.py", line 26, in <module>
    from future import standard_library
ImportError: No module named future
make[2]: *** [icarous-v2.0-cxx-stamp] Error 1
make[1]: *** [CMakeFiles/icarous.xml-v2.0.dir/all] Error 2
make[2]: *** [include/v1.0/icarous/icarous.h] Error 1
make[2]: *** [matrixpilot-v2.0-cxx-stamp] Error 1
make[1]: *** [CMakeFiles/icarous.xml-v1.0.dir/all] Error 2
make[1]: *** [CMakeFiles/matrixpilot.xml-v2.0.dir/all] Error 2
make: *** [all] Error 2
cd /home/liuyongke/catkin_ws/build/mavlink; catkin build --get-env mavlink | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
...............................................................................
Failed     << mavlink:make                 [ Exited with code 2 ]              
Failed    <<< mavlink                      [ 0.2 seconds ]                     
Abandoned <<< libmavconn                   [ Unrelated job failed ]            
Abandoned <<< mavros                       [ Unrelated job failed ]            
Abandoned <<< mavros_extras                [ Unrelated job failed ]            
Abandoned <<< test_mavros                  [ Unrelated job failed ]            
Finished  <<< mavros_msgs                  [ 1.4 seconds ]                     
[build] Summary: 1 of 6 packages succeeded.                                    
[build]   Ignored:   None.                                                     
[build]   Warnings:  None.                                                     
[build]   Abandoned: 4 packages were abandoned.                                
[build]   Failed:    1 packages failed.                                        
[build] Runtime: 1.5 seconds total. 

但是在安装future时,会出现已经安装的提示

$ sudo pip3 install future
The directory '/home/liuyongke/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/liuyongke/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: future in /home/liuyongke/.local/lib/python3.6/site-packages

 

这种情况可能是因为 Python 2 和 Python 3 在处理 futures 模块时有所不同。如果你的系统同时安装了这两个版本的 Python,那么在编译过程中就可能出现找不到或者无法使用 futures 模块的问题。

为了解决这个问题,你可以尝试以下几个步骤:

确认你正在使用 Python 2 或者 Python 3,然后安装或者更新对应版本的 futures 模块。你可以使用以下命令来安装 Python 2 和 Python 3 对应版本的 futures 模块:

对于 Python 2:sudo pip install futures

对于 Python 3:sudo pip3 install futures

如果你的系统同时安装了 Python 2 和 Python 3,而且两个版本的 futures 模块都安装了,那么你可以尝试删除其中一个版本的 futures 模块,然后重新编译。你可以使用以下命令来删除 Python 2 和 Python 3 对应版本的 futures 模块:

对于 Python 2:sudo pip uninstall futures

对于 Python 3:sudo pip3 uninstall futures

删除成功后,重新编译即可。

另外,在编译 mavros 之前,你应该确保你的系统已经安装了所有必须的依赖库和工具,这些依赖库和工具都可以在 mavros 的安装文档中找到。