繁体   English   中英

如何修复“UserWarning:Distutils 是在 Setuptools 之前导入的”?

[英]How to fix 'UserWarning: Distutils was imported before Setuptools'?

当我 git 克隆一些包含 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.

任何人都知道如何解决它?
~~~bash /opt/ros/noetic/lib/python3/dist-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils 在 Setuptools 之前被导入,但是导入 Setuptools 也会替换 `sys.modules 中的 `distutils` 模块`。 这可能会导致不良行为或错误。 为避免这些问题,请避免直接使用 distutils,确保以传统方式安装 setuptools(例如,不是可编辑的安装),和/或确保始终在 distutils 之前导入 setuptools。 ~~~

将系统升级到 20.04 和 ROS Noetic 后,我遇到了同样的问题。 正如这个答案中所建议的,升级setuptools解决了这个问题。

但我实际上会像这样pip3 install --user --upgrade pip setuptools进行用户安装,因为它避免了与系统 package 的冲突。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM