【问题标题】:Google Colab No Such File or Directory ErrorGoogle Colab 没有此类文件或目录错误
【发布时间】:2021-07-07 17:50:41
【问题描述】:

您好,我正在尝试在 google colab 上启动 tensorflow 训练过程。我正在尝试在 google colab 的集成笔记本中运行此代码块。代码块是:

!apt-get install protobuf-compiler python-pil python-lxml python-tk
!pip install Cython
%cd '/content/gdrive/My Drive/models/research/'
!protoc object_detection/protos/*.proto --python_out=.

import os
os.environ['PYTHONPATH'] += ':/content/gdrive/My Drive/models/research/:/content/gdrive/My Drive/models/research/slim'

!python setup.py build
!python setup.py install

它给出了这个输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
protobuf-compiler is already the newest version (3.0.0-9.1ubuntu1).
python-lxml is already the newest version (4.2.1-1ubuntu0.4).
python-pil is already the newest version (5.1.0-1ubuntu0.6).
python-tk is already the newest version (2.7.17-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
Requirement already satisfied: Cython in /usr/local/lib/python3.7/dist-packages (0.29.23)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/content/gdrive/My Drive/models/research
python3: can't open file 'setup.py': [Errno 2] No such file or directory
python3: can't open file 'setup.py': [Errno 2] No such file or directory

我想我无法正确设置 python 路径。谁能帮帮我?

【问题讨论】:

    标签: python tensorflow google-colaboratory


    【解决方案1】:

    您必须先挂载您的 Google 驱动器:

    from google.colab import drive
    drive.mount('/content/gdrive')
    

    试着去做

    import os
    os.listdir(os.getcwd())
    

    这应该返回

    ['.config', 'sample_data']
    

    在安装驱动器之前,并且

    ['.config', 'gdrive', 'sample_data']
    

    在您安装驱动器之后。

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多