conda虚拟环境下运行ROS程序

1.安装虚拟环境

# 下载最新版Miniconda安装脚本
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

# 运行安装脚本(默认安装到~/miniconda3)
bash Miniconda3-latest-Linux-x86_64.sh

2.创建虚拟环境

# 创建名为myenv的虚拟环境,指定Python版本(如3.9)
conda create -n ros_env python=3.8

# 激活环境
conda activate ros_env 

3. 将虚拟环境加入.bashrc

打开.bashrc文件,在文件末尾添加如下代码,其中CONDA_FLAG=1为标志位,判断是否等于1来选择是否进入虚拟环境

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
CONDA_FLAG=1
if [ $CONDA_FLAG -eq 1 ]; then
  __conda_setup="$('/home/ukz/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
  if [ $? -eq 0 ]; then
      eval "$__conda_setup"
  else
      if [ -f "/home/ukz/miniconda3/etc/profile.d/conda.sh" ]; then
          . "/home/ukz/miniconda3/etc/profile.d/conda.sh"
      else
          export PATH="/home/ukz/miniconda3/bin:$PATH"
      fi
  fi
  conda activate ros_env
  unset __conda_setup
fi
# <<< conda initialize <<<

4.新的环境缺少库依赖

通过鱼香ros补齐安装,根据提示选择对应序号换源并安装修复ROS1

# 下载并运行一键安装脚本
wget http://fishros.com/install -O fishros && . fishros

5. 安装其他依赖库

pip install numpy
pip install empy
pip install opencv-python
pip install PyQt5

6.安装OpenVINO需要的库

pip install openvino==2023.0.1
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容