Ubuntu操作遇到的报错解决方法汇总(持续更新)

本文介绍了在Anaconda虚拟环境中遇到的PyTorch相关问题及其解决方案,包括找不到Torch配置文件、C++版本不兼容、环境激活与删除、ROS控制器加载失败、SDL库缺失以及一系列ROS包的安装。通过修改环境变量、CMakeLists.txt文件和使用apt-get安装缺失依赖,可以解决这些问题。
部署运行你感兴趣的模型镜像

1、在anaconda中创建了虚拟环境并安装了pytorch,但是编译过程中仍然报没有torch的错误:

CMake Error at crawler_crane/crane_tutorials/CMakeLists.txt:23 (find_package):
  By not providing "FindTorch.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Torch", but
  CMake did not find one.

  Could not find a package configuration file provided by "Torch" with any of
  the following names:

    TorchConfig.cmake
    torch-config.cmake

  Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set
  "Torch_DIR" to a directory containing one of the above files.  If "Torch"
  provides a separate development package or SDK, be sure it has been
  installed.

解决方法:在隐藏文件 .bashrc 中添加以下语句:

export Torch_DIR="/home/kieran/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/share/cmake"

2、error: #error C++14 or later compatible compiler is required to use ATen.
#error You need C++14 to compile PyTorch
这个错误搜到了几种不同的解决方式:

   //方式一:在CMakeLists.txt文件中加入以下内容
    ADD_COMPILE_OPTIONS(-std=c++11 )
    ADD_COMPILE_OPTIONS(-std=c++14 )
    set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )
    //方式二:在CMakeLists.txt文件中加入以下内容
    add_compile_options(-std=c++11)
    add_compile_options(-std=c++14)
    set( CMAKE_CXX_STANDARD 14)

3、Anaconda中激活删除环境

conda create -n torch python=3.6 //用来创建新的虚拟环境
conda remove -n torch1 --all  //用来删除anaconda中的环境
conda config --set auto_activate_base false //解决默认进入虚拟环境
which python //用来查看python安装路径,应用于多版本python调用对照 
python --version //用来查看python对应版本

4、 (1)Failed to load rear_right_velocity_controller:
(2)Could not load controller ‘left_front_wheel_velocity_controller’ because controller type ‘effort_controllers/JointVelocityController’ does not exit::

sudo apt-get install ros-melodic-velocity-controllers

sudo apt-get install ros-melodic-effort-controllers

5、Could not find SDL_image(missing:SDL_IMAGE_LABRARIESSDL_IMAGE_INCLUDE_DIRS)

sudo apt-get install libsdl-image1.2-dev

6、Could not find SDL(missing:SDL_LIBRARY SDL_INCLUDE_DIR)

sudo apt-get install libsdl-dev 或 sudo apt-get install libsdl1.2-dev

7、ModuleNotFoundError:No module named ‘rospkg’:安装rospkg即可
8、ImportError:dynamic module does not define module export function(PyIntit__tf2):解决方法如下:

修改解释器为python2.7即可解决  #! /usr/bin/env python2.7

9、解决ROS中运行gazebo出现process has died的情况

killall gzserver

10、cc:50:10: fatal error: pcap.h: 没有那个文件或目录

解决方法:sudo apt-get install libpcap-dev

11、ERROR: cannot launch node of type [map_server/map_server]: map_server

sudo apt-get install ros-melodic-map-server
//下面还有一些类似的报错及安装包:
1、sudo apt-get install ros-melodic-tf2-sensor-msgs
2、sudo apt-get install ros-melodic-move-base-msgs
3、sudo apt-get install ros-melodic-serial
4、sudo apt-get install ros-melodic-geographic-msgs
5、sudo apt-get install ros-melodic-base-local-planner
6、sudo apt-get install ros-melodic-costmap-converter
7、sudo apt-get install ros-melodic-mbf-costmap-core
8、sudo apt-get install ros-melodic-mbf-msgs
9、sudo apt install ros-melodic-gmapping
10、sudo apt-get install ros-melodic-move-base

12、Unable to find SuiteSparse
Call Stack (most recent call first):
teb_local_planner/CMakeLists.txt:35 (find_package)

解决方法:sudo apt-get install libsuitesparse-dev

13、 Could not find libg2o!

解决方法:sudo apt-get install ros-melodic-libg2o

14、ERROR: cannot launch node of type [swri_transform_util/initialize_origin.py]: swri_transform_util

sudo apt-get install ros-melodic-mapviz ros-melodic-mapviz-plugins ros-melodic-tile-map ros-melodic-multires-image

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

### 解决方案 在 Ubuntu 18.04 系统中,当执行 `sudo apt update` 命令时,出现 `Err:1 http://cn.archive.ubuntu.com/ubuntu bionic InRelease Could not resolve 'us.archive.ubuntu.com'` 报错,通常是因为 DNS 解析问题或网络连接异常导致的。以下是详细的解决方法[^1]。 #### 修改 DNS 设置 DNS 解析失败是该问题的主要原因之一。可以通过修改系统的 DNS 配置来解决此问题。编辑 `/etc/resolv.conf` 文件,添加一个可靠的 DNS 服务器地址,例如 Google 的公共 DNS 或阿里云 DNS: ```bash sudo nano /etc/resolv.conf ``` 在文件中添加以下内容: ``` nameserver 8.8.8.8 nameserver 8.8.4.4 ``` 保存并退出后,重新运行 `sudo apt update` 命令以验证问题是否解决[^1]。 #### 更改 APT 源 如果 DNS 设置无误但问题仍然存在,可以尝试更改 APT 软件源为更稳定的镜像站点。例如,使用中科大的镜像源。编辑 `/etc/apt/sources.list` 文件: ```bash sudo nano /etc/apt/sources.list ``` 将文件中的所有内容替换为以下内容(适用于 Ubuntu 18.04 Bionic): ``` deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse ``` 保存并退出后,运行以下命令更新软件包列表: ```bash sudo apt update ``` #### 检查网络配置 如果上述方法均无效,可能是网络配置存在问题。检查系统的网络设置,确保网络连接正常,并且没有代理干扰。可以通过以下命令测试网络连通性: ```bash ping archive.ubuntu.com ``` 如果无法 ping 通目标地址,则需要检查本地网络环境或联系网络管理员解决网络问题[^3]。 #### 清理缓存 有时,APT 缓存损坏也可能导致此类问题。可以尝试清理缓存并重新初始化 APT 数据库: ```bash sudo rm -rf /var/lib/apt/lists/* sudo apt update ``` ### 示例代码 以下是一个完整的修复脚本示例: ```bash # 修改 DNS 配置 echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null # 替换 APT 源为中科大镜像 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse" | sudo tee /etc/apt/sources.list > /dev/null echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list > /dev/null echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list > /dev/null echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list > /dev/null # 更新软件包列表 sudo apt update ```
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值