While importing spacy (import spacy) I am getting ValueError: unknown locale: UTF-8.
I don't have such problems with any other Python library.
ValueError Traceback (most recent call last)
<ipython-input-1-cd990d92ffc3> in <module>()
----> 1 import spacy
2 from spacy import displacy
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/spacy/__init__.py in <module>()
2 from __future__ import unicode_literals
3
----> 4 from .cli.info import info as cli_info
5 from .glossary import explain
6 from .about import __version__
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/spacy/cli/__init__.py in <module>()
----> 1 from .download import download
2 from .info import info
3 from .link import link
4 from .package import package
5 from .profile import profile
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/spacy/cli/download.py in <module>()
8 import sys
9
---> 10 from .link import link
11 from ..util import prints, get_package_path
12 from .. import about
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/spacy/cli/link.py in <module>()
6
7 from ..compat import symlink_to, path2str
----> 8 from ..util import prints
9 from .. import util
10
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/spacy/util.py in <module>()
6 import pkg_resources
7 import importlib
----> 8 import regex as re
9 from pathlib import Path
10 import sys
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/regex.py in <module>()
681
682 # We define _pattern_type here after all the support objects have been defined.
--> 683 _pattern_type = type(_compile("", 0, {}))
684
685 # We'll define an alias for the 'compile' function so that the repr of a
/Users/pmigdal/anaconda3/lib/python3.5/site-packages/regex.py in _compile(pattern, flags, kwargs)
434 if _locale_sensitive.get(locale_key, True) or (flags & LOCALE) != 0:
435 # This pattern is, or might be, locale-sensitive.
--> 436 pattern_locale = _getlocale()[1]
437 else:
438 # This pattern is definitely not locale-sensitive.
/Users/pmigdal/anaconda3/lib/python3.5/locale.py in getlocale(category)
575 if category == LC_ALL and ';' in localename:
576 raise TypeError('category LC_ALL is not supported')
--> 577 return _parse_localename(localename)
578
579 def setlocale(category, locale=None):
/Users/pmigdal/anaconda3/lib/python3.5/locale.py in _parse_localename(localename)
484 elif code == 'C':
485 return None, None
--> 486 raise ValueError('unknown locale: %s' % localename)
487
488 def _build_localename(localetuple):
ValueError: unknown locale: UTF-8
I think you need to set export LC_ALL=en_US.UTF-8 in your terminal session before running jupyter. Jupyter should then inherit this environment variable.
Setting your locale is generally a good idea anyway, especially for natural language processing work. Without this, some of your print statements will fail, which is always frustrating.
Thx @honnibal!
I see that setting it in ~/.bash_profile helped (instead of typing it each time).
Yet - is UTF-8 not enough for printing functions?
¯_(ツ)_/¯
Sometimes I wish Bash made sense to me...But then I think, if I found Bash intuitive, what would that say about my intuition?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I think you need to set
export LC_ALL=en_US.UTF-8in your terminal session before running jupyter. Jupyter should then inherit this environment variable.Setting your locale is generally a good idea anyway, especially for natural language processing work. Without this, some of your print statements will fail, which is always frustrating.