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