1200wd / bitcoinlib

Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.
http://bitcoinlib.readthedocs.io/
GNU General Public License v3.0
604 stars 200 forks source link

OSError: Locale is currently set to 'utf-8'. This library needs the locale set to UTF-8 to function properly #343

Closed dwjorgeb closed 11 months ago

dwjorgeb commented 11 months ago

OSError: Locale is currently set to 'utf-8'. This library needs the locale set to UTF-8 to function properly

bitcoinlib/config/config.py L126:

elif locale.getpreferredencoding() != 'UTF-8':
    raise EnvironmentError("Locale is currently set to '%s'. "
                           "This library needs the locale set to UTF-8 to function properly" %
                           locale.getpreferredencoding())

This check should be case-insensitive, it is error-ing out on Python >=3.11, as locale.getpreferredencoding() changed from returning UTF-8 to utf-8

https://docs.python.org/3.11/library/locale.html#locale.getpreferredencoding

mccwdev commented 11 months ago

Fixed in commit 6c82ac40ac66cfec2fd010d7bbcf70d5df46e623

Also updated documentation. It is recommended to use Python in utf-8 mode when using this library: https://docs.python.org/3/using/windows.html#win-utf8-mode