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

NameError: global name 'api' is not defined #266

Closed
gabelilly opened this issue Mar 6, 2017 · 3 comments
Closed

NameError: global name 'api' is not defined #266

gabelilly opened this issue Mar 6, 2017 · 3 comments

Comments

@gabelilly
Copy link

I installed keyring as part of the mercurial-keyring package, but I'm running into the following error when attempting to set a password. I've tried multiple reinstalls, but nothing seems to be working. I'm not terribly familiar with python so this might be an obvious issue. Thanks for the help.

Password for 'bar' in 'foo':
Traceback (most recent call last):
  File "/usr/local/bin/keyring", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/keyring/cli.py", line 101, in main
    return cli.run(argv)
  File "/usr/local/lib/python2.7/site-packages/keyring/cli.py", line 64, in run
    set_password(service, username, password)
  File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/local/lib/python2.7/site-packages/keyring/backends/OS_X.py", line 36, in set_password
    except api.Error:
NameError: global name 'api' is not defined
@jaraco
Copy link
Owner

jaraco commented Mar 9, 2017

That error will occur when the API module fails to import.

Can you run this command?

$ /usr/local/lib/python2.7 -c "import keyring.backends._OS_X_API"

That should produce the underlying exception that's causing the module to be missing.

@gabelilly
Copy link
Author

Thanks for the help, got the issue solved. Missing the six package.

➜  ~ /usr/local/bin/python2.7 -c "import keyring.backends._OS_X_API"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/keyring/backends/_OS_X_API.py", line 6, in <module>
    import six
ImportError: No module named six

After installing that package (don't know how I didn't have it in the first place), the issue is resolved. Thanks again.

@jaraco
Copy link
Owner

jaraco commented Mar 19, 2017

I believe underlying issue is that six is undeclared. The reason that the tests didn't capture the failure is because six is installed by test environments (and in my day-to-day usage), so it wasn't caught earlier. Thanks for tracking it down.

@jaraco jaraco closed this as completed in 36fdb8a Mar 19, 2017
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

2 participants