Sorry, you need to enable JavaScript to visit this website.

You are here

Messaging api - Python - configuration is not defined

1 post / 0 new

Dave's picture
by Dave

Messaging api - Python - configuration is not defined

Hi

Apologies but I am a complete newbie at Python, GIT and this api. I could have set this up in Java/Maven ok but want to use Python. Unfortunatly I am not sure how packages work with Python.

I suspect my issue is down to lack of knowledge of Python and git rather than anything else.

I do not use GIT so downloaded the code directly from https://github.com/telstra/MessagingAPI-SDK-python.

Then performed pip install from the downloaded code. This shows the result which appears to have worked although there is a message indicating 'wheel' is not installed.

Z:\Systems Administration\Dave\Python>pip install C:\Users\dave\Downloads\MessagingAPI-SDK-python-master
Processing c:\users\dave\downloads\messagingapi-sdk-python-master
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
Collecting urllib3>=1.15
  Downloading urllib3-1.26.14-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 6.8 MB/s
Collecting six>=1.10
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting certifi
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 6.4 MB/s
Collecting python-dateutil
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 6.4 MB/s
Using legacy 'setup.py install' for Telstra-Messaging, since package 'wheel' is not installed.
Installing collected packages: six, urllib3, python-dateutil, certifi, Telstra-Messaging
    Running setup.py install for Telstra-Messaging ... done
Successfully installed Telstra-Messaging-1.0.7 certifi-2022.12.7 python-dateutil-2.8.2 six-1.16.0 urllib3-1.26.14
WARNING: You are using pip version 21.2.4; however, version 22.3.1 is available.
You should consider upgrading via the 'C:\Python310\python.exe -m pip install --upgrade pip' command.

Then copied the example from https://github.com/telstra/MessagingAPI-SDK-python into VSCode 1.74.3. Python 3.10.1 is installed and running ok

VSCode shows an error - "configuration not defined". However, other references are being found from the imports and VSCode shows package details when hovering over the imports (e.g. Telstra_Messaging).

The error log shows

Traceback (most recent call last):
  File "..............Python\TelstraSendSMS\TelstraSendSMS", line 9, in <module>
    configuration.host = "https://tapi.telstra.com/v2"
NameError: name 'configuration' is not defined

Can someone please point out the obvious to a newbie.

Thanks in advance

Dave

 

Please ignore this.

 

Found the problem.

The website example needs to define configuration like this before referencing

Adding this and the error stops

configuration = Telstra_Messaging.Configuration()

 

Thanks

Dave