(missing: Python3_INCLUDE_DIRS Python3_LIBRARIES Python3_NumPy_INCLUDE_DIRS Development NumPy Development.Module Development.Embed) (found version "3.8.12")
暂且直接用test_ws 新建workspace 只有一个cmakelist进行测试:
cmake_minimum_required(VERSION 3.16)
find_package(Python3 COMPONENTS NumPy)#
if (Python3_FOUND)
message(STATUS "Python3_EXECUTABLE: ${Python3_EXECUTABLE}")
message(STATUS "_Python3_EXECUTABLE: ${_Python3_EXECUTABLE}\n")
message(STATUS "Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}")
message(STATUS "_Python3_INCLUDE_DIR: ${_Python3_INCLUDE_DIR}\n")
message(STATUS "Python3_LIBRARY_DEBUG: ${Python3_LIBRARY_DEBUG}")
message(STATUS "_Python3_LIBRARY_DEBUG: ${_Python3_LIBRARY_DEBUG}\n")
message(STATUS "Python3_LIBRARY_RELEASE: ${Python3_LIBRARY_RELEASE}")
message(STATUS "_Python3_LIBRARY_RELEASE: ${_Python3_LIBRARY_RELEASE}\n")
message(STATUS "Python3_NumPy_INCLUDE_DIR: ${Python3_NumPy_INCLUDE_DIR}")
message(STATUS "_Python3_NumPy_INCLUDE_DIR: ${_Python3_NumPy_INCLUDE_DIR}\n")
endif()
相关参考链接
cmake 官方文档,有关python3
Cannot import numpy in Python 3.7 or Python 3.8 - Ubuntu 18.04
How to uninstall python 3.8 from Ubuntu after deleting the folder Python-3.8.0 using “rm -rf”?
gtest missing方案
相关细节性错误复制,基本全都是这个:
CMake Error at xxx/CMakeLists.txt:51 (add_library):
Target "xxx" links to target "Python3::Python" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
都… 这么老油条了 还找了近半个小时的解法
首先想到的就是切conda,直接用环境
然后宣告失败,切完后 有些protobuf,google相关包 路径找不到,摘取错误:
fatal error: google/protobuf/port_def.inc: No such file or directory
安装numpy
pip3 install numpy
宣告失败,走了10分钟才发现哦吼,这个怎么找到了python 3.8.12的版本去了,而我系统的python3是链接到python3.6的所以即使这样做也不能有效
set好路径
set(Python3_INCLUDE_DIR /usr/include/python3.6)
set(Python3_LIBRARIES /usr/lib/x86_64-linux-gnu/libpython3.6m.so)
set(Python3_NumPy_INCLUDE_DIR /usr/lib/python3/dist-packages/numpy/core/include)
失败,因为… Python3 Find那里 并不会根据set的路径找
直接卸载3.8
一开始sudo apt remove python-3.8 还不行,非得卸干净了才行(我也不知道为啥我系统上有3.8 正常不走ros我都是conda yyds!!!)
sudo apt-get -y purge python3.8
sudo apt-get -y autoremove
随后经过干净的卸载 emmm 然后就找到了
多说一句 记得删除build devel出来的文件夹 再catkin_make