Repository navigation
symbol not found on macOS 11 #525
Copy link
Copy link
Closed
Description
Describe the bug
I've tried installing keyring with pip3 globally and also with pipenv, both times whenever I try to use this module i'm getting the same error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/keyring/backends/macOS/__init__.py", line 38, in set_password
api.set_generic_password(self.keychain, service, username, password)
NameError: name 'api' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Berry/Projects/pipenv/IEX/creds.py", line 20, in <module>
save_cred()
File "/Users/Berry/Projects/pipenv/IEX/creds.py", line 9, in save_cred
keyring.set_password(service_name, 'username', username)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/keyring/core.py", line 60, in set_password
get_keyring().set_password(service_name, username, password)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/keyring/backends/macOS/__init__.py", line 39, in set_password
except api.KeychainDenied as e:
NameError: name 'api' is not defined
To Reproduce
My little test script is:
import getpass
import keyring
def save_cred():
service_name = 'Python_IEX'
username = input('What\'s your IEX username?\n')
password = getpass.getpass(prompt='Password: ', stream=None)
keyring.set_password(service_name, 'username', username)
keyring.set_password(service_name, username, password)
print(f'Credentials for user {username} saved successfully.')
def get_cred():
username = keyring.get_password(service_name, 'username')
password = keyring.get_password(service_name, 'password')
return username, password
save_cred()
Expected behavior
A clear and concise description of what you expected to happen.
Environment
- OS: [e.g. macOS]
MacOS Big Sur 11.5.2
$ pip list | grep keyring
keyring 23.1.0
$ keyring --list-backends
dlsym(RTLD_DEFAULT, SecItemAdd): symbol not found
keyring.backends.chainer.ChainerBackend (priority: -1)
keyring.backends.macOS.Keyring (priority: 5)
keyring.backends.fail.Keyring (priority: 0)
Reactions are currently unavailable
Activity
gtmanfred commentedon Aug 31, 2021
I am also experiencing this symbol not found bug.
ShawnROGrady commentedon Sep 3, 2021
I noticed this immediately after updating to big sur, appears to be related to https://stackoverflow.com/questions/62587131/macos-big-sur-python-ctypes-find-library-does-not-find-libraries-ssl-corefou
mitya57 commentedon Sep 4, 2021
Can you paste an error that this command gives you:
python3 -c 'import keyring.backends.macOS.api'?Cc @jaraco because you are an actual macOS user unlike me.
goldstar611 commentedon Sep 10, 2021
I just pip3 installed keyring and also receive this error.
goldstar611 commentedon Sep 10, 2021
Upgrading to Python 3.9.7 resolved the issue for me.
python3 -c 'import keyring.backends.macOS.api'returns no errors nowlukeallpress commentedon Sep 10, 2021
Same issue
I'm not interested in upgrading my python beyond what Anaconda has released.
goldstar611 commentedon Sep 10, 2021
I think it's out of the maintainers hands since this is an underlying issue with python's ffi library when used with OSX Big Sur. According to https://bugs.python.org/issue41100 python 3.8.10 will get the fix. According to https://docs.anaconda.com/anaconda/packages/py3.8_osx-64/ ships with python 3.8.8 currently.
lukeallpress commentedon Sep 10, 2021
Thanks for the clarity and doing my research for me! I hadn't put the pieces together.
jaraco commentedon Sep 11, 2021
I can confirm the error is shown when running the tests on Python 3.8.5:
And also confirm that updating to Python 3.8.10 (universal binary) fixes the issue. Since 3.9.5 was released on the same date, I expect the fix to require that version as well.
Checking the changelog for 3.9.5, I don't see anything relevant. My guess is that the universal binary is required for Python 3.9.1 and 3.8.7 or later.
I don't believe this library can address the root cause, but it may be useful for this library to disable the backend when the API is unavailable (opening up the possibility of another macOS backend that bypasses the API).
jaraco commentedon Sep 11, 2021
I filed #529 to track the possible enhancement to not fail with the error reported above.
[-]NameError: name 'api' is not defined[/-][+]dlsym(RTLD_DEFAULT, SecItemAdd): symbol not found on macOS 11[/+][-]dlsym(RTLD_DEFAULT, SecItemAdd): symbol not found on macOS 11[/-][+]symbol not found on macOS 11[/+]goldstar611 commentedon Sep 12, 2021
It's there, but in the full HTML view as bpo-41100, https://docs.python.org/release/3.9.5/whatsnew/changelog.html#id33
jaraco commentedon Sep 12, 2021
Right, so it's not a specific Python version that matters but you must have a universal binary, which was introduced in Python 3.9.1 and 3.8.7, but the error will still occur on the latest releases of Python 3.8 and 3.9 if not using the universal binary, as observed above with reports of the failure on Python 3.9.2 and 3.8.8.
daweimau commentedon Oct 10, 2021
@jaraco is this an example of a universal binary installer that you'd expect to fix this issue?
jaraco commentedon Oct 11, 2021
Yes. The “universal2” in the name is the clue. These installers were introduced as part of the ARM support, and they seem to have the necessary symbols. For Python 3.10 and maybe 3.9, it may be your only option.