Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named jwt.algorithms #91

Closed
direvus opened this issue Aug 17, 2015 · 16 comments
Closed

ImportError: No module named jwt.algorithms #91

direvus opened this issue Aug 17, 2015 · 16 comments

Comments

@direvus
Copy link
Contributor

direvus commented Aug 17, 2015

After installing pyxero 0.7.0 via pip, and attempting to connect to a Private Application, I get the following ImportError:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/xero/manager.py", line 177, in wrapper
    params=params, cert=cert, timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 60, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 443, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 374, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 308, in prepare
    self.prepare_auth(auth, url)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 492, in prepare_auth
    r = auth(self)
  File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth1_auth.py", line 87, in __call__
    unicode(r.url), unicode(r.method), None, r.headers)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/__init__.py", line 150, in get_oauth_signature
    sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/signature.py", line 505, in sign_rsa_sha1_with_client
    return sign_rsa_sha1(base_string, client.rsa_key)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/signature.py", line 496, in sign_rsa_sha1
    alg = _jwt_rs1_signing_algorithm()
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth1/rfc5849/signature.py", line 473, in _jwt_rs1_signing_algorithm
    import jwt.algorithms as jwtalgo
ImportError: No module named jwt.algorithms

I've tried this on Gentoo and Ubuntu, with the same results. On Gentoo, I then installed pyjwt with pip, and got this:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/xero/manager.py", line 177, in wrapper
    params=params, cert=cert, timeout=timeout)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 122, in put
    return request('put', url, data=data, **kwargs)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 451, in request
    prep = self.prepare_request(req)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 382, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 308, in prepare
    self.prepare_auth(auth, url)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 496, in prepare_auth
    r = auth(self)
  File "/usr/lib64/python2.7/site-packages/requests_oauthlib-0.5.0-py2.7.egg/requests_oauthlib/oauth1_auth.py", line 79, in __call__
    unicode(r.url), unicode(r.method), r.body or '', r.headers)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/__init__.py", line 150, in get_oauth_signature
    sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/signature.py", line 505, in sign_rsa_sha1_with_client
    return sign_rsa_sha1(base_string, client.rsa_key)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/signature.py", line 496, in sign_rsa_sha1
    alg = _jwt_rs1_signing_algorithm()
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/signature.py", line 474, in _jwt_rs1_signing_algorithm
    _jwtrs1 = jwtalgo.RSAAlgorithm(jwtalgo.hashes.SHA1)
AttributeError: 'module' object has no attribute 'RSAAlgorithm'

Installing python-jwt on the Ubuntu machine made no difference.

PyCrypto is installed (2.6.1) on both machines. JWT appears to be required, pip doesn't install it automatically as a dependency, but even when it is installed, the thing doesn't seem to be able to load up the crypto libraries it wants. Am I taking crazy pills, or is something very wrong here?

@aidanlister
Copy link
Collaborator

I think one of our dependencies has changed and it's throwing up this stuff. See #90 for a possible fix.

@direvus
Copy link
Contributor Author

direvus commented Aug 17, 2015

Hi @aidanlister, thanks for your response. Installing dev-python/cryptography changed the error on Gentoo, but python-cryptography was already installed on Debian.

The new traceback on Gentoo is:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/xero/manager.py", line 177, in wrapper
    params=params, cert=cert, timeout=timeout)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 451, in request
    prep = self.prepare_request(req)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 382, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 308, in prepare
    self.prepare_auth(auth, url)
  File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 496, in prepare_auth
    r = auth(self)
  File "/usr/lib64/python2.7/site-packages/requests_oauthlib-0.5.0-py2.7.egg/requests_oauthlib/oauth1_auth.py", line 87, in __call__
    unicode(r.url), unicode(r.method), None, r.headers)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/__init__.py", line 128, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/__init__.py", line 210, in _render
    request.oauth_params, request.headers, realm=realm)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/utils.py", line 31, in wrapper
    return target(params, *args, **kwargs)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/parameters.py", line 57, in prepare_headers
    escaped_value = utils.escape(value)
  File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/utils.py", line 56, in escape
    'Got %s of type %s.' % (u, type(u)))
ValueError: Only unicode objects are escapable. Got None of type <type 'NoneType'>.

@aidanlister
Copy link
Collaborator

It must have something to do with the changes happening in oauthlib:
https://github.com/idan/oauthlib/releases

There's been new releases in the past few days ... can you try downgrading
to an older version?

On Mon, 17 Aug 2015 at 23:50 direvus [email protected] wrote:

Hi @aidanlister https://github.com/aidanlister, thanks for your
response. Installing dev-python/cryptography changed the error on Gentoo,
but python-cryptography was already installed on Debian.

The new traceback on Gentoo is:

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.7/site-

packages/xero/manager.py", line 177, in wrapper
params=params, cert=cert, timeout=timeout)
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 69, in get
return request('get', url, params=params, *_kwargs)
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/api.py", line 50, in request
response = session.request(method=method, url=url, *_kwargs)
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 451, in request
prep = self.prepare_request(req)
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/sessions.py", line 382, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 308, in prepare
self.prepare_auth(auth, url)
File "/usr/lib64/python2.7/site-packages/requests-2.7.0-py2.7.egg/requests/models.py", line 496, in prepare_auth
r = auth(self)
File "/usr/lib64/python2.7/site-packages/requests_oauthlib-0.5.0-py2.7.egg/requests_oauthlib/oauth1_auth.py", line 87, in call
unicode(r.url), unicode(r.method), None, r.headers)
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/init.py", line 313, in sign
('oauth_signature', self.get_oauth_signature(request)))
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/init.py", line 128, in get_oauth_signature
uri, headers, body = self._render(request)
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/init.py", line 210, in _render
request.oauth_params, request.headers, realm=realm)
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/utils.py", line 31, in wrapper
return target(params, _args, *_kwargs)
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/parameters.py", line 57, in prepare_headers
escaped_value = utils.escape(value)
File "build/bdist.linux-x86_64/egg/oauthlib/oauth1/rfc5849/utils.py", line 56, in escape
'Got %s of type %s.' % (u, type(u)))
ValueError: Only unicode objects are escapable. Got None of type <type 'NoneType'>.


Reply to this email directly or view it on GitHub
#91 (comment).

@direvus
Copy link
Contributor Author

direvus commented Aug 17, 2015

Tried 0.7.1, 0.7.2, 1.0.0, 1.0.1 and 1.0.2 of oauthlib, no change.

@direvus
Copy link
Contributor Author

direvus commented Aug 18, 2015

Sorry, a correction to my previous comment. My results were messed up by a problem with my testing script. The error "ValueError: Only unicode objects are escapable. Got None of type <type 'NoneType'>." seems to be what happens if you try to use PrivateCredentials with a consumer key of None. pyxero could possibly do some validation on this and throw a more helpful error message, but that's a different issue.

The error "AttributeError: 'module' object has no attribute 'RSAAlgorithm'" is the real one, and it is indeed related to version >= 1.0.0 of oauthlib. Downgrading to oauthlib 0.7.2 seems to resolve the problem.

@jevonearth
Copy link

I think this issue is still valid. The requirements definition is pulling in wrong/incompatible dependencies. Try using the library using a fresh virtualenv.

@jamesjryan
Copy link

Can confirm this issue is still current in a fresh virtualenv.

Jamess-MacBook-Pro:.virtual-env james$ virtualenv pyxerotest
New python executable in pyxerotest/bin/python
Installing setuptools, pip, wheel...done.
Jamess-MacBook-Pro:.virtual-env james$ source ./pyxerotest/bin/activate
(pyxerotest)Jamess-MacBook-Pro:.virtual-env james$ ls
pyxerotest
(pyxerotest)Jamess-MacBook-Pro:.virtual-env james$ sudo pip install pyxero
Password:
The directory '/Users/james/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The directory '/Users/james/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyxero
  Downloading pyxero-0.7.0-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.3.0 (from pyxero)
  Downloading requests_oauthlib-0.5.0-py2.py3-none-any.whl
Collecting six>=1.8.0 (from pyxero)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from pyxero)
  Downloading python_dateutil-2.4.2-py2.py3-none-any.whl (188kB)
    100% |████████████████████████████████| 192kB 1.9MB/s
Collecting requests>=1.1.0 (from pyxero)
  Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
    100% |████████████████████████████████| 499kB 753kB/s
Collecting pycrypto>=2.6.1 (from pyxero)
Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.3.0->pyxero)
Installing collected packages: requests, oauthlib, requests-oauthlib, six, python-dateutil, pycrypto, pyxero
Successfully installed oauthlib-1.0.3 pycrypto-2.6.1 python-dateutil-2.4.2 pyxero-0.7.0 requests-2.8.1 requests-oauthlib-0.5.0 six-1.10.0
(pyxerotest)Jamess-MacBook-Pro:.virtual-env james$ ipython
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from xero import Xero

In [2]: from xero.auth import PrivateCredentials

In [3]: with open('/Users/james/privatekey.pem') as keyfile:    rsa_key = keyfile.read()
   ...:

In [4]: credentials = PrivateCredentials('removed....', rsa_key)

In [5]: xero = Xero(credentials)

In [6]: print xero.contacts.all()---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-8fbe7fe51597> in <module>()
----> 1 print xero.contacts.all()

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/xero/manager.pyc in wrapper(*args, **kwargs)
    175             response = getattr(requests, method)(
    176                     uri, data=body, headers=headers, auth=self.credentials.oauth,
--> 177                     params=params, cert=cert, timeout=timeout)
    178
    179             if response.status_code == 200:

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/api.pyc in get(url, params, **kwargs)
     67
     68     kwargs.setdefault('allow_redirects', True)
---> 69     return request('get', url, params=params, **kwargs)
     70
     71

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/api.pyc in request(method, url, **kwargs)
     48
     49     session = sessions.Session()
---> 50     response = session.request(method=method, url=url, **kwargs)
     51     # By explicitly closing the session, we avoid leaving sockets open which
     52     # can trigger a ResourceWarning in some cases, and look like a memory leak

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    452             hooks = hooks,
    453         )
--> 454         prep = self.prepare_request(req)
    455
    456         proxies = proxies or {}

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/sessions.pyc in prepare_request(self, request)
    386             auth=merge_setting(auth, self.auth),
    387             cookies=merged_cookies,
--> 388             hooks=merge_hooks(request.hooks, self.hooks),
    389         )
    390         return p

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/models.pyc in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
    295         self.prepare_cookies(cookies)
    296         self.prepare_body(data, files, json)
--> 297         self.prepare_auth(auth, url)
    298
    299         # Note that prepare_auth must be last to enable authentication schemes

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests/models.pyc in prepare_auth(self, auth, url)
    485
    486             # Allow auth to make its changes.
--> 487             r = auth(self)
    488
    489             # Update self to reflect the auth changes.

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/requests_oauthlib/oauth1_auth.pyc in __call__(self, r)
     85             # Omit body data in the signing of non form-encoded requests
     86             r.url, headers, _ = self.client.sign(
---> 87                 unicode(r.url), unicode(r.method), None, r.headers)
     88
     89         r.prepare_headers(headers)

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.pyc in sign(self, uri, http_method, body, headers, realm)
    311         # generate the signature
    312         request.oauth_params.append(
--> 313             ('oauth_signature', self.get_oauth_signature(request)))
    314
    315         # render the signed request and return it

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.pyc in get_oauth_signature(self, request)
    148             raise ValueError('Invalid signature method.')
    149
--> 150         sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
    151
    152         log.debug("Signature: {0}".format(sig))

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/signature.pyc in sign_rsa_sha1_with_client(base_string, client)
    503     if not client.rsa_key:
    504         raise ValueError('rsa_key is required when using RSA signature method.')
--> 505     return sign_rsa_sha1(base_string, client.rsa_key)
    506
    507

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/signature.pyc in sign_rsa_sha1(base_string, rsa_private_key)
    494         base_string = base_string.encode('utf-8')
    495     # TODO: finish RSA documentation
--> 496     alg = _jwt_rs1_signing_algorithm()
    497     key = _prepare_key_plus(alg, rsa_private_key)
    498     s=alg.sign(base_string, key)

/Users/james/.virtual-env/pyxerotest/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/signature.pyc in _jwt_rs1_signing_algorithm()
    471     global _jwtrs1
    472     if _jwtrs1 is None:
--> 473         import jwt.algorithms as jwtalgo
    474         _jwtrs1 = jwtalgo.RSAAlgorithm(jwtalgo.hashes.SHA1)
    475     return _jwtrs1

ImportError: No module named jwt.algorithms

In [7]:

@nkeilar
Copy link

nkeilar commented Dec 10, 2015

Downgrading to oauthlib 0.7.2 seems to resolve the problem as a work around. I'm not doing anything mission critical, just a local script but is still an issue.

@saaa-hsjgrobler
Copy link

I am also getting the exact same error message with a fresh install.
Downgrading to oauthlib 0.7.2 worked for me as well.

@ccsalway
Copy link

I tried the downgrade option but now I'm getting

File "purchases.py", line 69, in
xero.invoices.put(invoices)
File "/usr/local/lib/python2.7/dist-packages/xero/manager.py", line 177, in wrapper
params=params, cert=cert, timeout=timeout)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 105, in put
return request('put', url, data=data, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 420, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

@timrichardson
Copy link
Contributor

Installing
pip install cryptography
as per #90
fixed it for me (Python 3.5.1, latest release of all packages)

@flybonzai
Copy link

I'm running into this same problem on Python 3.5.1. Here is the traceback:

Traceback (most recent call last):
File "/Users/mharris/PycharmProjects/etl3/jira_fixversions.py", line 46, in
authed_jira = JIRA(oauth=oauth_dict)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/jira/client.py", line 261, in init
si = self.server_info()
File "/Users/mharris/anaconda/lib/python3.5/site-packages/jira/client.py", line 1619, in server_info
return self._get_json('serverInfo')
File "/Users/mharris/anaconda/lib/python3.5/site-packages/jira/client.py", line 2035, in _get_json
r = self._session.get(url, params=params)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/jira/resilientsession.py", line 130, in get
return self.__verb('GET', url, *_kwargs)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/jira/resilientsession.py", line 109, in __verb
response = method(url, *_kwargs)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests/sessions.py", line 480, in get
return self.request('GET', url, **kwargs)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests/sessions.py", line 454, in request
prep = self.prepare_request(req)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests/sessions.py", line 388, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests/models.py", line 297, in prepare
self.prepare_auth(auth, url)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests/models.py", line 490, in prepare_auth
r = auth(self)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/requests_oauthlib/oauth1_auth.py", line 88, in call
unicode(r.url), unicode(r.method), None, r.headers)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/init.py", line 313, in sign
('oauth_signature', self.get_oauth_signature(request)))
File "/Users/mharris/anaconda/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/init.py", line 150, in get_oauth_signature
sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 505, in sign_rsa_sha1_with_client
return sign_rsa_sha1(base_string, client.rsa_key)
File "/Users/mharris/anaconda/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 496, in sign_rsa_sha1
alg = _jwt_rs1_signing_algorithm()
File "/Users/mharris/anaconda/lib/python3.5/site-packages/oauthlib/oauth1/rfc5849/signature.py", line 473, in _jwt_rs1_signing_algorithm
import jwt.algorithms as jwtalgo
ImportError: No module named 'jwt.algorithms'

I've made sure cryptography is installed, still receiving this error.

@innerteapot
Copy link

I just got this error using pyxero 0.7.0 with Python 2.7.6 on pythonanywhere.com. Downgrading to oauthlib 0.7.2 solved the issue for me.

pip install oauthlib==0.7.2

@aidanlister
Copy link
Collaborator

Can you try upgrading to pyxero==0.8.0?

@innerteapot
Copy link

Created a new venv and installed 0.8.0 but got a different error message:

AttributeError: 'module' object has no attribute 'RSAAlgorithm'

Installed cryptography as per issue 90 and everything is working now.

Here's what pip reports as installed (just in case it's useful):

(xero-invoice-consolidator2) 05:09 ~/src/xero-invoice-consolidator (master)$ pip list
cffi (1.5.2)
cryptography (1.3.1)
enum34 (1.1.2)
idna (2.1)
ipaddress (1.0.16)
oauthlib (1.0.3)
ordereddict (1.1)
peewee (2.8.0)
pip (8.1.1)
pyasn1 (0.1.9)
pycparser (2.14)
PyJWT (1.4.0)
PyMySQL (0.7.2)
python-dateutil (2.5.2)
pyxero (0.8.0)
PyYAML (3.11)
requests (2.9.1)
requests-oauthlib (0.6.1)
setuptools (20.3.1)
six (1.10.0)
wheel (0.29.0)
(xero-invoice-consolidator2) 05:10 ~/src/xero-invoice-consolidator (master)$ 

Thanks :)

@romarpatindol
Copy link

I changed the dependencies to:
pycrypto 2.6.1
cryptography 1.3.1
oauthlib 0.7.2

Luckily, it works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests