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

You are here

Cant install module via Pip

5 posts / 0 new
Last post

James's picture
by James

Cant install module via Pip

Requested Telstra-Messaging from https://files.pythonhosted.org/packages/f7/b6/51054e127830df6a06791dcc895ee03ca8087a542cadf269c9ed66de64ca/Telstra_Messaging-1.0.6.1.tar.gz#sha256=e5185836ead2dfb0f0fd0ca542ff8cb05cdba06565f204b6bf85c45bd0eec564 has inconsistent version: filename has '1.0.6.1', but metadata has '1.0.6'.

ERROR: Could not find a version that satisfies the requirement Telstra-Messaging
ERROR: No matching distribution found for Telstra-Messaging

 

Currently have the above message when installing telstra_messaging module from command prompt for python, has anyone else run into this issue or possibly know the reason why?

Vinodh's picture
by Vinodh

Cant install module via Pip

Hi James,

Sorry to hear that there was version mismatch in our python package.  I have forwarded this issue to our dev team to check this out.

I shall let you know once I have a response from our dev team.

 

Regards,

Vinodh

Vinodh's picture
by Vinodh

Cant install module via Pip

Hi James,

Our dev team checked your issue but could not reproduce the issue.  Here is the output of our pip install, get token and send sms using python sdk.  Could you please check this and send your log if you still have issues?

 

# Telstra Messaging SDK Python

## Below is download SDK.

```SHELL
macosc:osx ~/dev/telstra/tls-messaging-py $ docker run -it --rm --name tls-messaging-py -v "$PWD":/usr/src/app -w /usr/src/app python:3 bash
root@c58db25f2406:/usr/src/app# pip install git+https://github.com/Telstra/MessagingAPI-SDK-python.git
Collecting git+https://github.com/Telstra/MessagingAPI-SDK-python.git
  Cloning https://github.com/Telstra/MessagingAPI-SDK-python.git to /tmp/pip-req-build-3fsskqcw
Collecting six>=1.10
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting urllib3>=1.15
  Downloading urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
     |████████████████████████████████| 137 kB 6.0 MB/s
Collecting certifi
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 8.8 MB/s
Collecting python-dateutil
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 12.2 MB/s
Building wheels for collected packages: Telstra-Messaging
  Building wheel for Telstra-Messaging (setup.py) ... done
  Created wheel for Telstra-Messaging: filename=Telstra_Messaging-1.0.7-py3-none-any.whl size=61666 sha256=ff1af8021d87b9bd98565e684a48b1b2d7f833eee4b3ae1efd21036523448368
  Stored in directory: /tmp/pip-ephem-wheel-cache-9_o1ao45/wheels/b8/23/c0/8837a310782bf6c58eb4fc1a10cb78ca658f12451644b39505
Successfully built Telstra-Messaging
Installing collected packages: six, urllib3, python-dateutil, certifi, Telstra-Messaging
Successfully installed Telstra-Messaging-1.0.7 certifi-2020.12.5 python-dateutil-2.8.1 six-1.15.0 urllib3-1.26.3
WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
root@c58db25f2406:/usr/src/app#
```

## Obtain an auth token.

```SHELL
root@c58db25f2406:/usr/src/app# python3
Python 3.9.1 (default, Jan 12 2021, 16:45:25)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import time
>>> import Telstra_Messaging
st import ApiException
from pprint import pprint
api_instance = Telstra_Messaging.AuthenticationApi()
client_id = '<REDACTED>'  # str |
client_secret = '<REDACTED>'  # str |
grant_type = 'client_credentials'  # str |  (default to 'client_credentials')
scope = 'scope_example'  # str | NSMS (optional)
try:
    # Generate OAuth2 token
    api_response = api_instance.auth_token(
        client_id, client_secret, grant_type, scope=scope)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AuthenticationApi->auth_token: %s\n" % e)
>>> from Telstra_Messaging.rest import ApiException
>>> from pprint import pprint
>>> api_instance = Telstra_Messaging.AuthenticationApi()
>>> client_id = '<REDACTED>'  # str |
>>> client_secret = '<REDACTED>'  # str |
>>> grant_type = 'client_credentials'  # str |  (default to 'client_credentials')
>>> scope = 'scope_example'  # str | NSMS (optional)
>>> try:
...     # Generate OAuth2 token
...     api_response = api_instance.auth_token(
...         client_id, client_secret, grant_type, scope=scope)
...     pprint(api_response)
... except ApiException as e:
...     print("Exception when calling AuthenticationApi->auth_token: %s\n" % e)
...
{'access_token': '<REDACTED>',
 'expires_in': '3599',
 'token_type': 'Bearer'}
>>> exit()
root@c58db25f2406:/usr/src/app#
```

## Send an SMS.

```SHELL
root@c58db25f2406:/usr/src/app# python3
Python 3.9.1 (default, Jan 12 2021, 16:45:25)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import time
>>> import Telstra_Messaging
st import ApiException
from pprint import pprint
configuration = Telstra_Messaging.Configuration()
# Configure OAuth2 access token for authorization: auth
configuration.access_token = '<REDACTED>'

# Defining host is optional and default to https://tapi.telstra.com/v2
configuration.host = "https://tapi.telstra.com/v2"
# Create an instance of the API class
api_instance = Telstra_Messaging.MessagingApi(
    Telstra_Messaging.ApiClient(configuration))
# SendSMSRequest | A JSON or XML payload containing the recipient's phone number and text message. This number can be in international format if preceeded by a '+' or in national format ('04xxxxxxxx') where x is a digit.
payload = Telstra_Messaging.SendSMSRequest(
    '<REDACTED>', 'Hello World from Telstra Message SDK')

try:
    # Send SMS
    api_response = api_instance.send_sms(payload)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling MessagingApi->send_sms: %s\n" % e)
>>> from Telstra_Messaging.rest import ApiException
>>> from pprint import pprint
>>> configuration = Telstra_Messaging.Configuration()
>>> # Configure OAuth2 access token for authorization: auth
>>> configuration.access_token = '<REDACTED>'
>>>
>>> # Defining host is optional and default to https://tapi.telstra.com/v2
>>> configuration.host = "https://tapi.telstra.com/v2"
>>> # Create an instance of the API class
>>> api_instance = Telstra_Messaging.MessagingApi(
...     Telstra_Messaging.ApiClient(configuration))
>>> # SendSMSRequest | A JSON or XML payload containing the recipient's phone number and text message. This number can be in international format if preceeded by a '+' or in national format ('04xxxxxxxx') where x is a digit.
>>> payload = Telstra_Messaging.SendSMSRequest(
...     '<REDACTED>', 'Hello World from Telstra Message SDK')
>>>
>>> try:
...     # Send SMS
...     api_response = api_instance.send_sms(payload)
...     pprint(api_response)
... except ApiException as e:
...     print("Exception when calling MessagingApi->send_sms: %s\n" % e)
...
{'country': [{'UNK': 1}],
 'message_type': 'SMS',
 'messages': [{'delivery_status': 'MessageWaiting',
               'message_id': '<REDACTED>',
               'message_status_url': 'https://tapi.telstra.com/v2/messages/sms/<REDACTED>/status',
               'to': '<REDACTED>'}],
 'number_segments': 1}
>>> exit()
root@c58db25f2406:/usr/src/app#
```

 

Andrew's picture
by Andrew

Two fixes for the issue

I've had the same issue, the problem is that the package on PyPI has mismatching metadata, and recent versions of pip will complain about this. If you visit: https://pypi.org/project/Telstra-Messaging/#files, the version in the metadata (1.0.6) does not match that in the .tar.gz file (1.0.6.1).

The script Vinodh used downloaded from the Telstra-Messaging repository on GitHub, which is version 1.0.7. PyPI is still on 1.0.6/1.0.6.1.

The Telstra-messaging package page on PyPI needs to be updated to fix the mismatch, then updated to have the latest package.

There are two workarounds.

1 - Get the package from GitHub, like Vinodh did.

2 - Roll back to a version of Pip that does not perform the metadata check. 20.1 installs Telstra-Messaging from PyPI without complaint, 20.3.1 will throw the metadata check error. Rolling back to 20.1 will allow you to install Telstra-Messaging from PyPI without needing to spend time getting and installing the wheel file, until they fix the metadata on PyPI and you can remove the version lock on pip:

$ pip install pip=20.1

$ pip install telstra-messaging

-Andy

Vinodh's picture
by Vinodh

Two fixes for the issue

Hi Andy,

Thanks for providing the feedback and possible workarounds to fix this issue.  Really appreciate your inputs.

As informed over emal we are in the process of updating our SDKs and Python SDK is work in progress.  We will definetly ensure issues such as these do not arise in the future by updating our build scripts and our documentation to support our developer community better.

 

Regards

Vinodh

Log in or register to post comments