Ändern Sie die Python -Version in Google ColabPython

Python-Programme
Guest
 Ändern Sie die Python -Version in Google Colab

Post by Guest »

Ich bin durch verschiedene Ausgänge verwirrt, wenn ich versuche, die in Google Colab verwendete Python -Version zu überprüfen.
In meinem Projekt brauche ich eine bestimmte Python -Version. Version.
Ich mache das mit diesem Code: < /p>
!apt-get update -y
!update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!update-alternatives --config python3
!apt install python3-pip
!apt install python3.7-distutils
< /code>
Ich überprüfe die Version auf vier verschiedene Arten: < /p>
!python --version
import sys
print("User Current Version:-", sys.version)
import platform
print(platform.python_version())
import os
os.system("python --version")
< /code>
und erhalten Sie diese Ausgabe: < /p>
Python 3.7.17
User Current Version:- 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
3.10.12
0
< /code>
Basierend auf meinem Verständnis der SYS.VERSION -Methode sollte die wirklich verwendete Version zurückgeben. So installieren Sie unter Python 3.7.17.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post