ROS修改:ubuntu系统更改默认python版本(重要操作)

ubuntu18.04+ROS melodic

困扰:ROS用到python2,而各种目标检测源码用到python3,而且各种包也要安在python3的环境下,而不是python2.

解决:基于update-alternatives

1.怎么出现的问题

在安装pytorch时发现安装适用于python3.6以上的pytorch版本时出现找不到对应的pytorch版本,而且提示有老的版本,说明在python版本中pip install默认用了python2.*没用python3.*。

rosmelodic@rosmelodic-virtual-machine:~$ pip install torch==1.8.0+cpu torchvision==0.9.0+cpu torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.8.0+cpu
  Could not find a version that satisfies the requirement torch==1.8.0+cpu (from versions: 0.1.6.post17, 0.1.6.post20, 0.1.6.post22, 0.1.7.post2, 0.1.8.post1, 0.1.9.post1, 0.1.9.post2, 0.1.10.post1, 0.1.10.post2, 0.1.11.post4, 0.1.11.post5, 0.1.12.post1, 0.1.12.post2, 0.2.0.post1, 0.2.0.post2, 0.2.0.post3, 0.3.0, 0.3.0.post2, 0.3.0.post3, 0.3.0.post4, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.2.0+cpu, 1.2.0+cu92, 1.3.0, 1.3.0+cpu, 1.3.0+cu100, 1.3.0+cu92, 1.3.1, 1.3.1+cpu, 1.3.1+cu100, 1.3.1+cu92, 1.4.0, 1.4.0+cpu, 1.4.0+cu100, 1.4.0+cu92, 1.5.0+cpu, 1.5.0+cu92)
No matching distribution found for torch==1.8.0+cpu

ubuntu18.04,python版本

rosmelodic@rosmelodic-virtual-machine:~$ python
Python 2.7.17 (default, Jul  1 2022, 15:56:32) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
rosmelodic@rosmelodic-virtual-machine:~$ python3
Python 3.6.9 (default, Jun 29 2022, 11:45:57) 
[GCC 8.4.0] on linux
Type "help", "copyri
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值