我第一次尝试从Google colab运行python文件。 我已将文件以及所需的文件夹上传到驱动器(作为参考,我正在尝试运行此项目https://github.com/Cartucho/mAP) 然后,我将文件安装到驱动器上,将目录更改为map项目并按以下方式运行文件:
from google.colab import drive
drive.mount('/content/drive')
%cd "/content/drive/My Drive/map"
!python main.py
但是我不断得到:无法连接到X服务器。我有什么想念吗?
谢谢!
答案 0 :(得分:0)
尝试一下,让我知道您是否仍然有问题:
# Import PyDrive and associated libraries.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth, drive
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
GoogleDrive = GoogleDrive(gauth)
# Mount Google Drive for file import
drive.mount('/content/drive')
%cd "/content/drive/My Drive/map"
!python main.py