Closed nikhilsharma010 closed 6 years ago
This should hopefully be easy to resolve – see this section in the troubleshooting guide:
ValueError: unknown locale: UTF-8
This error can sometimes occur on OSX and is likely related to a still unresolved Python bug. However, it's easy to fix: just add the following to your
~/.bash_profile
or~/.zshrc
and then runsource ~/.bash_profile
orsource ~/.zshrc
. Make sure to add both lines forLC_ALL
andLANG
.export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
I already did that
Nikhils-MacBook-Air:~ nikhil$ sudo nano ~/.bash_profile Password: Nikhils-MacBook-Air:~ nikhil$ source ~/.bash_profile Nikhils-MacBook-Air:~ nikhil$ cat ~/.zshrc cat: /Users/nikhil/.zshrc: No such file or directory Nikhils-MacBook-Air:~ nikhil$ sudo nano ~/.zshrc Nikhils-MacBook-Air:~ nikhil$ source export LC_ALL=en_US.UTF-8 -bash: export: No such file or directory Nikhils-MacBook-Air:~ nikhil$ export LANG=en_US.UTF-8 Nikhils-MacBook-Air:~ nikhil$ source ~/.zshrc Nikhils-MacBook-Air:~ nikhil$
still I am getting the same error while importing
Could you run the locale
command in your terminal and share the output?
Nikhils-MacBook-Air:~ nikhil$ locale LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL="en_US.UTF-8" Nikhils-MacBook-Air:~ nikhil$
That all looks correct. Is that the same in Jupyter? Maybe the problem is that your Juypter environment uses different locale settings. You could try the following to check:
import locale
print(locale.getlocale())
When I run this in Jupyer notebook
I get the same error.
ValueError Traceback (most recent call last)
When I run the same command in my terminal it gives back the following and runs without error
import locale print(locale.getlocale()) ('en_US', 'UTF-8') import spacy nlp = spacy.load('en')
But in Jupyter this isn't working giving the same error
Also I am new to programming and python so may be some of the issues might be easy but i may not be able to figure that out. I think this is an environment issue can you help redirect in the right direction to solve that
The issue is solved when I used following command
Nikhils-MacBook-Air:~ nikhil$ sudo conda install -c conda-forge spacy
now if I do import spacy it works fine however
if I write
nlp = spacy.load('en')
it given me Keyerror: 'package'
Glad you got the locale thing working! I'm surprised this worked, but maybe conda actually fixed the locale stuff in your environment when you reinstalled spaCy 🙂 I'll answer the other question in #2571.
@nikhilsharma010 Thank you for your command script. That's work for me.
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.
I installed Spacy and initially I encountered errors with installation but those have been fixed thanks to I looked at earlier queries. Still I when I do import spacy on jupyter I get ValueError: unknown locale: UTF-8
But in my terminal it shows it is installed
Nikhils-MacBook-Air:~ nikhil$ sudo python -m spacy download en Password: Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB) 100% |████████████████████████████████| 37.4MB 1.7MB/s Requirement already satisfied (use --upgrade to upgrade): en-core-web-sm==2.0.0 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz in /anaconda3/lib/python3.6/site-packages