-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using protobuf case #547
Comments
how to import protobuf generations? |
@lilothar Try: |
@elisbyberi I have try that, but raise error too test_pb2.py:5:4-23: error: cannot import name 'version_info' from 'sys'
test_pb2.py:6:6-30: error: no module named 'google.protobuf.internal'
test_pb2.py:7:6-21: error: no module named 'google.protobuf'
test_pb2.py:8:6-21: error: no module named 'google.protobuf'
test_pb2.py:9:6-21: error: no module named 'google.protobuf'
test_pb2.py:10:6-21: error: no module named 'google.protobuf'
test_pb2.py:13:11-37: error: no module named '_symbol_database' another example that define a class A, class A:
x: int
def __init__(self, x):
self.x = x codon test file: a_test.codon from python import ftest
print(ftest.A(1).x) codon run a_test.codon will run ok class A:
def __init__(self, y: int):
self.x: int = y this will case the same type error with using protobuf as bellow error: 'pyobj' object has no attribute 'x' I guss if I want to import a python class, I should definitely define the data member with type in python, thus to protobuf, |
@lilothar Refer to: https://docs.exaloop.io/codon/interoperability/python for information on how to work with the google.protobuf library. TL;DR: You have to import it from Python using Note that a 'Python module' is a pip-installed Python module (importable from the Python runtime). If you want to import a Python script (from the same directory), you can simply use |
@elisbyberi I have try that method, but no effect and raise
|
This looks like a bug on our end. Will take a look—thanks for the report! |
defines
test.proto
run generation cmd
protoc ./test.proto --python_out=./
write proto.codon
run
codon run proto.codon
The text was updated successfully, but these errors were encountered: