python 如何修复“用户警告:Distutils是在Setuptools之前导入的?

jv2fixgn  于 2022-12-17  发布在  Python
关注(0)|答案(1)|浏览(1821)

当我克隆了一些包含python工具的软件包时,出现了一个错误:

Errors     << unique_id:cmake /home/scpark/cps_ws/logs/unique_id/build.cmake.001.log                                              
CMake Warning (dev) at CMakeLists.txt:2 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

/opt/ros/noetic/lib/python3/dist-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
  warnings.warn(
/opt/ros/noetic/lib/python3/dist-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

ERROR: invalid command 'unique_id'
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):

  execute_process(/home/scpark/cps_ws/build/unique_id/catkin_generated/env_cached.sh
  "/usr/bin/python3"
  "/opt/ros/noetic/share/catkin/cmake/interrogate_setup_dot_py.py"
  "unique_id" "/home/scpark/cps_ws/src/unique_identifier/unique_id/setup.py"
  "/home/scpark/cps_ws/build/unique_id/catkin_generated/setup_py_interrogation.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/catkin_python_setup.cmake:46 (safe_execute_process)
  CMakeLists.txt:8 (catkin_python_setup)

cd /home/scpark/cps_ws/build/unique_id; catkin build --get-env unique_id | catkin env -si  /usr/bin/cmake /home/scpark/cps_ws/src/unique_identifier/unique_id --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/scpark/cps_ws/devel/.private/unique_id -DCMAKE_INSTALL_PREFIX=/home/scpark/cps_ws/install; cd -

..................................................................................................................................
Failed     << unique_id:cmake                  [ Exited with code 1 ]                                                             
Failed    <<< unique_id                        [ 0.5 seconds ]                                                                    
Abandoned <<< unique_identifier                [ Unrelated job failed ]                                                           
[build] Summary: 1 of 3 packages succeeded.                                                                                       
[build]   Ignored:   None.                                                                                                        
[build]   Warnings:  None.                                                                                                        
[build]   Abandoned: 1 packages were abandoned.                                                                                   
[build]   Failed:    1 packages failed.                                                                                           
[build] Runtime: 0.7 seconds total.

有人知道怎么修吗?
/opt/ros/noetic/lib/python3/分布式软件包/_distutils_hack/初始化.py:18:用户警告:Distutils是在Setuptools之前导入的,但导入Setuptools还会替换sys.modules中的distutils模块。这可能会导致不良行为或错误。若要避免这些问题,请避免直接使用distutils,确保以传统方式安装setuptools(例如,不是可编辑安装),和/或确保始终在distutils之前导入setuptools。

9njqaruj

9njqaruj1#

我在将系统升级到20. 04和ROS Noetic后也遇到了同样的问题,正如this answer中所建议的,升级setuptools解决了这个问题。
但实际上我会像pip3 install --user --upgrade pip setuptools这样进行用户安装,因为它避免了与系统包的冲突。

相关问题