【问题标题】:cannot connect to X server when running a python file on google colab在 google colab 上运行 python 文件时无法连接到 X 服务器
【发布时间】:2020-06-30 14:01:58
【问题描述】:

我第一次尝试从 google colab 运行 python 文件。 我将文件以及所需的文件夹上传到我的驱动器(作为参考,我正在尝试运行这个项目https://github.com/Cartucho/mAP) 然后,我将文件挂载到我的驱动器,将目录更改为地图项目并运行文件,如下所示:

from google.colab import drive
drive.mount('/content/drive')
%cd "/content/drive/My Drive/map"
!python main.py

但我不断收到:无法连接到 X 服务器。我有什么遗漏吗?

谢谢!

【问题讨论】:

标签: python google-colaboratory


【解决方案1】:

试试这个,如果还有问题,请告诉我:

# 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

【讨论】:

    猜你喜欢
    • 2021-03-26
    • 2013-07-07
    • 1970-01-01
    • 2019-12-22
    • 2023-03-14
    • 2019-07-26
    • 2020-07-01
    • 2020-04-28
    • 2014-08-10
    相关资源
    最近更新 更多