Skip to content

ImportError with Python 3 #23

@gadams999

Description

@gadams999

Hi SDK team,

I saw that 1.1.0 was released and upgraded from 1.0.1. However, an from ... import statement that was working under Python 3.5.1 is now throwing an ImportError. I've create a new virtualenv via pyenv and pip installed just the AWSIoTPythonSDK. When I try to do the from import:

$ python
Python 3.5.1 (default, Feb 16 2016, 16:56:48) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[redacted]/.pyenv/versions/3.5.1/envs/iot_test/lib/python3.5/site-packages/AWSIoTPythonSDK/MQTTLib.py", line 18, in <module>
    import core.protocol.mqttCore as mqttCore
ImportError: No module named 'core'
>>> 

It looks like the import statements in core/protocol/mqttCore have been changed from relative imports to absolute imports starting with the package root (AWSIoTPythonSDK).

Performing the same test with a clean 2.7.10 virtualenv operates as expected:

$ pip install AWSIoTPythonSDK
Collecting AWSIoTPythonSDK
  Using cached AWSIoTPythonSDK-1.1.0.tar.gz
Building wheels for collected packages: AWSIoTPythonSDK
  Running setup.py bdist_wheel for AWSIoTPythonSDK
  Stored in directory: /[redacted]/Library/Caches/pip/wheels/65/4c/8d/70428fd5ea7d7e201fc2b5e3f83ea57dfdc450304c064f4ea1
Successfully built AWSIoTPythonSDK
Installing collected packages: AWSIoTPythonSDK
Successfully installed AWSIoTPythonSDK-1.1.0
$ python
Python 2.7.10 (default, Dec  3 2015, 15:37:46) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
>>> 

Is there something I'm missing from an environment aspect in 3.5.1?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions