0

I've been writing a Python SDK for code generated from Protobuf. I have it uploaded to Test PyPI and am able to download it by doing:

pip install -i https://test.pypi.org/simple/ alphausblue

This downloads the package to my the store associated with my conda environment, test. I have confirmed that the code's distribution info is located in \anaconda3\envs\test\Lib\site-packages\alphausblue-0.1.0.dist-info and that the code itself is located in \anaconda3\envs\test\Lib\site-packages\alphausblue and if I try to do any of the following, I get no error:

import alphausblue
import alphausblue.org
import alphausblue.org.v1
import alphausblue.org.v1 as org
from alphausblue.org.v1 import *

Furthermore, if I do the following:

import alphausblue.org.v1 as org
org

then the interpreter prints <module 'alphausblue.org.v1' from '\anaconda3\envs\test\lib\site-packages\alphausblue\org\v1\__init__.py'>. Navigating to this location, I see the associated files are there. However, if I try to do:

org.Organization
from alphausblue.org.v1 import Organization

I get the following error:

ImportError: cannot import name 'Organization' from 'alphausblue.org.v1' (\anaconda3\envs\test\lib\site-packages\alphausblue\org\v1_init_.py)

I've researched this error here but this doesn't seem related. How do I fix this import error?

1 Answer 1

1

You need to import Organization in alphausblue\org\v1\__init__.py:

from .org_pb2_grpc import Organization
Sign up to request clarification or add additional context in comments.

2 Comments

So I can't just leave the __init__.py file in each directory empty? These files are generated so I'd like to avoid inserting custom code in them if possible
Ah sorry, this ended up being a much more stupid problem than I had originally thought.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.