為什麼當我安裝了 Tensorflow 的所有庫後,會出現無目錄錯誤? (Why do I get a no directory error, when I have installed all the libraries for Tensorflow?)


問題描述

為什麼當我安裝了 Tensorflow 的所有庫後,會出現無目錄錯誤? (Why do I get a no directory error, when I have installed all the libraries for Tensorflow?)

我正在關注本教程:https://github.com/RomRoc /objdet_train_tensorflow_colab/blob/master/objdet_custom_tf_colab.ipynb

當我嘗試運行第一個代碼塊時:


!apt‑get install ‑qq protobuf‑compiler python‑tk

!pip install ‑q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install ‑q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto ‑‑python_out=.

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

!python object_detection/builders/model_builder_test.py

我收到此錯誤:

/content
object_detection/protos/*.proto: No such file or directory
python3: can't open file 'object_detection/builders/model_builder_test.py': [Errno 2] No such file or directory

正如教程所說,我已經在 Google Colab 中安裝了所有庫,所以我不明白為什麼會出現此錯誤或如何修復它。任何幫助將不勝感激。


參考解法

方法 1:

I am able to recreate your issue in Google Colab

!apt‑get install ‑qq protobuf‑compiler python‑tk

!pip install ‑q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install ‑q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto ‑‑python_out=.

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

!python object_detection/builders/model_builder_test.py

Output:

[Errno 2] No such file or directory: '/root/models/research'
/content
object_detection/protos/*.proto: No such file or directory
python3: can't open file 'object_detection/builders/model_builder_test.py': [Errno 2] No such file or directory

Solution: To fix this issue, you can change your current directory /content to /root/models/research by including below two lines before running your code.

%cd
!git clone ‑‑quiet https://github.com/tensorflow/models.git

Here is the updated code

%cd

!git clone ‑‑quiet https://github.com/tensorflow/models.git

!apt‑get install ‑qq protobuf‑compiler python‑tk

!pip install ‑q Cython contextlib2 pillow lxml matplotlib PyDrive

!pip install ‑q pycocotools

%cd ~/models/research
!protoc object_detection/protos/*.proto ‑‑python_out=.

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

!python object_detection/builders/model_builder_test.py

Output:

/root
/root/models/research
2020‑05‑08 15:23:47.035256: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1

(by SwalkrTensorflow Warrior)

參考文件

  1. Why do I get a no directory error, when I have installed all the libraries for Tensorflow? (CC BY‑SA 2.5/3.0/4.0)

#protocol-buffers #Python #google-colaboratory #TensorFlow #apt






相關問題

通過 Method.invoke() 調用靜態方法給了我 NPE (Static method invocation via Method.invoke() gave me NPE)

python中的protobuf到json (Protobuf to json in python)

如何序列化/反序列化使用 ScalaPB 的“oneof”的 protobuf 消息? (How to serialize/deserialize a protobuf message that uses 'oneof' with ScalaPB?)

序列化和反序列化未知的繼承類型 (Serializing and deserializing unknown inherited types)

Thrift 與協議緩衝區 (Thrift vs Protocol buffers)

如何在客戶端排除導入 (How to exclude an import on client side)

為什麼當我安裝了 Tensorflow 的所有庫後,會出現無目錄錯誤? (Why do I get a no directory error, when I have installed all the libraries for Tensorflow?)

如何為 C# <proto/> 定義傳遞experimental_allow_proto3_optional 以在proto3 中啟用可選? (How to pass experimental_allow_proto3_optional for C# <proto/> definitions to enable optional in proto3?)

CentOS7 的 libprotobuf-lite.so 文件在 CentOS8 機器上工作嗎? (is libprotobuf-lite.so file from CentOS7 working in CentOS8 machine?)

protogen - 支持 <Property> 指定的語法 (protogen - support the <Property>Specified syntax)

.Net 字典類型在 protobuff (.Net dictionary type in protobuff)

為什麼 protobuf 更喜歡代碼生成器而不是運行時動態加載 (why protobuf prefer code-generator other than dynamic loading at runtime)







留言討論