python - Google Colab 没有此类文件或目录错误
问题描述
您好,我正在尝试在 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 路径。任何人都可以帮助我吗?
解决方案
你必须先挂载你的谷歌驱动器:
from google.colab import drive
drive.mount('/content/gdrive')
试着做
import os
os.listdir(os.getcwd())
这应该返回
['.config', 'sample_data']
在安装驱动器之前,以及
['.config', 'gdrive', 'sample_data']
安装驱动器后。
推荐阅读
- c# - 尝试在 MVC 和 Web 窗体站点之间共享 cookie 的重定向循环
- c - 将字符数组作为函数参数传递
- html - 如何将 HTML/CSS 的形式更改为 JSON?
- xml - 如何在 XSLT 中使用“xsl:apply-templates”获取 XML 属性值
- windows - Inno Setup 制作的安装程序需要海拔高度。我该如何避免呢?
- git - Git revert 不恢复文件
- powershell - Powershell 复制上次修改的文件
- scala - Scala 类扩展了 Trait
- matlab - MATLAB .fig 到网格文件?
- ios - 如何使用 Xcode 在 SideMenu 上将徽标居中