TheThingsArchive / python-app-sdk

The Things Network Application SDK for Python
MIT License
29 stars 16 forks source link

ImportError: No module named apif #27

Closed bkircher67 closed 6 years ago

bkircher67 commented 6 years ago

Hello,

I tried to run the example code on Ubuntu 18.04, but it already failed when running import ttn

on Python 2.7.15rc1 it ends with:

Traceback (most recent call last): File "ttn_test.py", line 2, in import ttn File "/home/bernd/.local/lib/python2.7/site-packages/ttn/init.py", line 1, in from .ttnmqtt import MQTTClient File "/home/bernd/.local/lib/python2.7/site-packages/ttn/ttnmqtt.py", line 12, in from .discovery import DiscoveryClient File "/home/bernd/.local/lib/python2.7/site-packages/ttn/discovery.py", line 7, in import ttn.github_com.TheThingsNetwork.api.discovery.discovery_pb2_grpc \ File "/home/bernd/.local/lib/python2.7/site-packages/ttn/github_com/TheThingsNetwork/api/discovery/init.py", line 1, in from .discovery_pb2 import * File "/home/bernd/.local/lib/python2.7/site-packages/ttn/github_com/TheThingsNetwork/api/discovery/discovery_pb2.py", line 17, in from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 ImportError: No module named api

with Python 3.6.5 it fails too:

Traceback (most recent call last): File "ttn_test.py", line 2, in import ttn File "/home/bernd/.local/lib/python3.6/site-packages/ttn/init.py", line 1, in from .ttnmqtt import MQTTClient File "/home/bernd/.local/lib/python3.6/site-packages/ttn/ttnmqtt.py", line 12, in from .discovery import DiscoveryClient File "/home/bernd/.local/lib/python3.6/site-packages/ttn/discovery.py", line 7, in import ttn.github_com.TheThingsNetwork.api.discovery.discovery_pb2_grpc \ File "/home/bernd/.local/lib/python3.6/site-packages/ttn/github_com/TheThingsNetwork/api/discovery/init.py", line 1, in from .discovery_pb2 import * File "/home/bernd/.local/lib/python3.6/site-packages/ttn/github_com/TheThingsNetwork/api/discovery/discovery_pb2.py", line 17, in from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 ModuleNotFoundError: No module named 'google.api'

BTW I have installed google.api with pip before trying this.

KR Bernd

gtmtg commented 6 years ago

Try pip install googleapis-common-protos

(or, more broadly, install all the requirements for this package with pip install -r requirements.txt in the package directory)

egourlao commented 6 years ago

Thanks for the bug report! I can indeed reproduce the problem in a ubuntu:18.04 Docker container. @gtmtg's suggestion is correct: running pip install googleapis-common-protos (or using requirements.txt) solves it. I'll investigate why this is happening - contributions are welcome!

egourlao commented 6 years ago

I've released a new version, 2.1.3, which ships with @gtmtg's changes to dependencies. Can you confirm that this solves the problem on your side?

bkircher67 commented 6 years ago

@gtmtg: Thank you! Yes, installing this package helped to fix my problem. Great!