Issue:我正在試圖安裝a Python3 port of Google Protocol Buffers。當我做一個python3 setup.py test
我得到以下錯誤:Python相對輸入語法:`from。 import abc.xyz`
File "/[*snip*]/python3-protobuf-master/python/google/protobuf/unittest_custom_options_pb2.py", line 13
from . import google.protobuf.descriptor_pb2
^
SyntaxError: invalid syntax
然後我試過類似的語法在我的兩個Python3和Python2解釋,並得到了同樣的錯誤:
Python 3.2.3 (default, Jul 23 2012, 16:48:24)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from . import x.y
File "<stdin>", line 1
from . import x.y
^
SyntaxError: invalid syntax
問:當是from . import abc.xyz
有效的Python語法,如果有的話?我有興趣知道我下載的代碼是否內在地格式錯誤。
其他:我選擇GPB這Python3端口從一個答案上this SO question.這是達不到最新的關於GPB,但我希望它仍然起作用。讓我知道你是否更瞭解GPB的Python3端口。
哪裏是'unittest_custom_options_pb2.py'文件從何而來? IT不在您鏈接到的[GitHub存儲庫](https://github.com/openx/python3-protobuf/tree/master/python/google/protobuf)中。 –
啊,它似乎是從[此文件](https://github.com/openx/python3-protobuf/blob/master/src/google/protobuf/unittest_custom_options.proto)自動生成的。 –
是的,這兩個違規文件中的每一行的第1行都說'#由協議緩衝區編譯器生成。不要編輯!'但是我按照你的建議編輯了它們,'setup.py test'運行正常。 – turbulencetoo