如何更改google colab上使用的python版本

2024-04-29 08:32:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试安装此回购:

https://github.com/CMU-Perceptual-Computing-Lab/MonocularTotalCapture

在谷歌colab上。这就是我安装conda和opencv=2.4.13的方式(它需要python 2.7才能工作)

pip install conda

!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh

!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local

import sys

sys.path.append('/usr/local/lib/python3.6/site-packages/')

!conda install -y -q -c conda-forge opencv=2.4.13

在其他软件包之间,它还需要pyEDM,所以我正在尝试安装它。我遵循以下指南:

https://github.com/SugiharaLab/pyEDM/issues/1

在执行以下命令之前,我不会得到任何错误:

!cd pyEDM; pip install .

这给了我一个错误:

Processing /content/pyEDM
ERROR: Package 'pyEDM' requires a different Python: 2.7.15 not in '>=3'

事实上,当我问我有哪些版本的python时,它会说:

!python2 --version
Python 2.7.15

!python3 --version
Python 3.6.9

!echo $PYTHONPATH
/tensorflow-1.15.0/python3.6:/env/python

因此,在安装opencv 2.4.13后,我应该将conda安装的python版本更改为3或更高版本,否则无法安装包。在本地计算机上,我将使用以下命令执行此操作:

!alias python='/usr/bin/python3.6'

但它在colab上不起作用。当我发出alias命令时,它不会回答任何问题,错误仍然存在。我能做什么


Tags: installhttps命令版本githubcomlinuxusr