This question already has answers here:
Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"
(6 answers)
Closed 7 years ago.
I run the python script that contain Pandas (that one cause the problem) library I got this error:
Traceback (most recent call last):
File "test.py", line 2, in <module>
import pandas
ImportError: No module named pandas
But if I import from package path to make sure it detects Pandas library, I got this error message
Traceback (most recent call last):
File "test.py", line 3, in <module>
import pandas
File "/usr/local/lib/python2.7/site-packages/pandas/__init__.py", line 44, in <module>
from pandas.core.api import *
File "/usr/local/lib/python2.7/site-packages/pandas/core/api.py", line 9, in <module>
from pandas.core.groupby import Grouper
File "/usr/local/lib/python2.7/site-packages/pandas/core/groupby.py", line 16, in <module>
from pandas.core.frame import DataFrame
File "/usr/local/lib/python2.7/site-packages/pandas/core/frame.py", line 41, in <module>
from pandas.core.series import Series
File "/usr/local/lib/python2.7/site-packages/pandas/core/series.py", line 2864, in <module>
import pandas.tools.plotting as _gfx
File "/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py", line 28, in <module>
import pandas.tseries.converter as conv
File "/usr/local/lib/python2.7/site-packages/pandas/tseries/converter.py", line 7, in <module>
import matplotlib.units as units
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
I already update my .bash_profile and .bashrc with these lines but still not working even I already restart the terminal and my machine.
export LANG="it_IT.UTF-8"
export LC_COLLATE="it_IT.UTF-8"
export LC_CTYPE="it_IT.UTF-8"
export LC_MESSAGES="it_IT.UTF-8"
export LC_MONETARY="it_IT.UTF-8"
export LC_NUMERIC="it_IT.UTF-8"
export LC_TIME="it_IT.UTF-8"
export LC_ALL="it_IT.UTF-8"
I'm also enabled Set locale environment variables on startup in the terminal preferences.
I'm afraid the problem caused because of El Capitan.
Edit: Pandas, and its dependencies, had localization bugs that were discovered in non-C locales and fixed in recent versions.
When I downloaded the latest version of Pandas onto an OS X Yosemite computer via sudo pip install pandas in a terminal set to it_IT.UTF-8, and then imported it in a new Python session, I wasn't able to reproduce this issue.
My best guess now - and I'd emphasize this is only a guess - is that the version of Pandas in that folder predates those fixes and is broken in it_IT.UTF-8. (I do think this is, on balance, more likely than the issue being specific to El Capitan.)
Your LC_ALL= is unset. That seems unusual; based on other answers here I think you should try setting it to LC_ALL="it_IT.UTF-8" and remove the other LC_ settings.
Then save your .bash_profile, open a new terminal tab, and try again.
Related
I am trying to get Arelle working on Ubuntu linux 18.04 with Python 3.6.9.
Step-1: (Download Arelle software):
git clone https://github.com/Arelle/Arelle.git -b lxml
Step-2 Install Python LXML:
apt-get install -y python-lxml
Step-3 Install Python tk:
Due to error: 'No module named tkinter'
...I install:
apt-get install python3-tk
When it's time to start Arelle from terminal, I use:
python3 arelleGUI.pyw
I then get following error:
Traceback (most recent call last):
File "arelleGUI.pyw", line 9, in <module>
from arelle import CntlrWinMain
File "/tmp3/Arelle/arelle/CntlrWinMain.py", line 22, in <module>
from arelle import Cntlr
File "/tmp3/Arelle/arelle/Cntlr.py", line 8, in <module>
from arelle import ModelManager
File "/tmp3/Arelle/arelle/ModelManager.py", line 8, in <module>
from arelle import (ModelXbrl, Validate, DisclosureSystem)
File "/tmp3/Arelle/arelle/Validate.py", line 9, in <module>
from arelle import (ModelXbrl, ModelVersReport, XbrlConst, ModelDocument,
File "/tmp3/Arelle/arelle/ModelVersReport.py", line 9, in <module>
from arelle import (XbrlConst, XbrlUtil, XmlUtil, UrlUtil, ModelXbrl, ModelDocument, ModelVersObject)
File "/tmp3/Arelle/arelle/ModelDocument.py", line 9, in <module>
from arelle import (XbrlConst, XmlUtil, UrlUtil, ValidateFilingText, XmlValidate)
File "/tmp3/Arelle/arelle/ValidateFilingText.py", line 16, in <module>
docCheckPattern = re.compile(r"&\w+;|[^0-9A-Za-z`~!##$%&\*\(\)\.\-+ \[\]\{\}\|\\:;\"'<>,_?/=\t\n\r\m\f]") # won't match &#nnn;
File "/usr/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/usr/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib/python3.6/sre_parse.py", line 527, in _parse
code1 = _class_escape(source, this)
File "/usr/lib/python3.6/sre_parse.py", line 336, in _class_escape
raise source.error('bad escape %s' % escape, len(escape))
sre_constants.error: bad escape \m at position 67
I found this SO question that seems related to the issue.
This is an error in Arelle, which shows up for Python 3.6 and later. There is a pull request for it , but that is still open (since July 2017). Given that Python 3.6 has been out for quite a while, I don't know why this hasn't been fixed.
You are using the lxml branch, which has been stale for 10 years. So perhaps this error has actually been fixed (even if the pull request is still open) on the master brach, but not on the lxml branch. Try installing from master first, if that is an option for you.
Yesterday I installed the mysql connector package, today I can't start python anymore. Anacona won't start nor directly Python 3.6. The Anaconda prompt delivered:
Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\ric22>python.exe -m idlelib.idle
Error processing line 1 of C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site-packages\protobuf-3.5.2.post1-py3.6-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "D:\Programme\Anaconda\pkgs\sqlalchemy-1.1.13-py36h5948d12_0\Lib\site-packages\sqlalchemy\dialects\mysql\types.py", line 9, in <module>
from ... import exc, util
ImportError: attempted relative import with no known parent package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 544, in <module>
main()
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 531, in main
known_paths = addsitepackages(known_paths)
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 328, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\site.py", line 178, in addpackage
import traceback
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\linecache.py", line 8, in <module>
import functools
File "C:\Users\ric22\AppData\Local\Programs\Python\Python36\lib\functools.py", line 22, in <module>
from types import MappingProxyType
File "D:\Programme\Anaconda\pkgs\sqlalchemy-1.1.13-py36h5948d12_0\Lib\site-packages\sqlalchemy\dialects\mysql\types.py", line 9, in <module>
from ... import exc, util
ImportError: attempted relative import with no known parent package
Does anyone have an idea how to make Python run again? Thanks in Advance
Ric
Thanks amphibient,
I had set this environment variable 'cause I couldn't make mysql package work on Spyder:
D:\Programme\Anaconda\pkgs\sqlalchemy-1.1.13-py36h5948d12_0\Lib\site-packages\sqlalchemy\dialects\mysql\types.py
(Now I see .py is obviously no folder ;))
This messed everything up. I removed it and installed the package with
conda install mysql-connector-python typed into conda path.
Now everything works.
This question already has answers here:
Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"
(6 answers)
Closed 6 years ago.
After installing the latest Mac OSX 64-bit Anaconda Python distribution, I keep getting a ValueError when trying to start the IPython Notebook.
Starting ipython works fine:
3-millerc-~:ipython
Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
But starting ipython notebook:
4-millerc-~:ipython notebook
Results in the ValueError (with traceback):
Traceback (most recent call last):
File "/Users/millerc/anaconda/bin/ipython", line 7, in <module>
launch_new_instance()
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 313, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/core/application.py", line 325, in initialize
self.parse_command_line(argv)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 308, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 420, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 352, in initialize_subcommand
subapp = import_item(subapp)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/utils/importstring.py", line 40, in import_item
module = __import__(package,fromlist=[obj])
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookapp.py", line 46, in <module>
from .handlers import (LoginHandler, LogoutHandler,
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/handlers.py", line 36, in <module>
from docutils.core import publish_string
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
from docutils.io import FileOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 503, in getdefaultlocale
return _parse_localename(localename)
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Running the locale command from the terminal:
5-millerc-~:locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
I summarize here the solution to be found on: http://blog.lobraun.de/2009/04/11/mercurial-on-mac-os-x-valueerror-unknown-locale-utf-8/
I added these lines to my .bash_profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
I reloaded the profile:
source ~/.bash_profile
I then ran ipython again:
ipython notebook
Changing locales
The above will work for the English language in a US locale. One may want different settings.
At the risk of stating the obvious, to discover the current settings for your system, use:
$ locale
And to retrieve a list of all valid settings on your system:
$ locale -a
Then choose your preferred locale. For example, for a Swiss French locale, the solution would look like this:
export LC_ALL=fr_CH.UTF-8
export LANG=fr_CH.UTF-8
This is a bug in the OS X Terminal app that only shows up in certain locales (country/language combinations). Open Terminal in /Applications/Utilities and uncheck the box “Set locale environment variables on startup”.
This will set your LANG environment variable to be empty. This may cause terminal use to incorrect settings for your locale. The locale command in the Terminal will tell you what settings are used. To use the correct language, add a line to your bash profile (typically ~/.profile)
export LANG=your-lang
Replace your-lang with the correct locale specifier for your language. The command locale -a will show you all the specifiers. For example, the language code for US English is en_US.UTF-8. The locale affects what translations are used when they are available, and also how dates, currencies, and decimals are formatted.
Note, this image and content were taken from http://conda.pydata.org/docs/troubleshooting.html#unknown-locale (I'm also the original author of that page).
in iTerm going to the menu
Preferences -> Profiles -> Terminal -> (Environment)
and then unchecking
"Set locale variables automatically"
made this error go away.
As your LC_CTYPE is wrong, you should find out where that wrong value is set and change it to something like en_US.UTF-8.
This question already has answers here:
Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"
(6 answers)
Closed 6 years ago.
After installing the latest Mac OSX 64-bit Anaconda Python distribution, I keep getting a ValueError when trying to start the IPython Notebook.
Starting ipython works fine:
3-millerc-~:ipython
Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
But starting ipython notebook:
4-millerc-~:ipython notebook
Results in the ValueError (with traceback):
Traceback (most recent call last):
File "/Users/millerc/anaconda/bin/ipython", line 7, in <module>
launch_new_instance()
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 313, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/core/application.py", line 325, in initialize
self.parse_command_line(argv)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 308, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 420, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 352, in initialize_subcommand
subapp = import_item(subapp)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/utils/importstring.py", line 40, in import_item
module = __import__(package,fromlist=[obj])
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookapp.py", line 46, in <module>
from .handlers import (LoginHandler, LogoutHandler,
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/handlers.py", line 36, in <module>
from docutils.core import publish_string
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
from docutils.io import FileOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 503, in getdefaultlocale
return _parse_localename(localename)
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Running the locale command from the terminal:
5-millerc-~:locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
I summarize here the solution to be found on: http://blog.lobraun.de/2009/04/11/mercurial-on-mac-os-x-valueerror-unknown-locale-utf-8/
I added these lines to my .bash_profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
I reloaded the profile:
source ~/.bash_profile
I then ran ipython again:
ipython notebook
Changing locales
The above will work for the English language in a US locale. One may want different settings.
At the risk of stating the obvious, to discover the current settings for your system, use:
$ locale
And to retrieve a list of all valid settings on your system:
$ locale -a
Then choose your preferred locale. For example, for a Swiss French locale, the solution would look like this:
export LC_ALL=fr_CH.UTF-8
export LANG=fr_CH.UTF-8
This is a bug in the OS X Terminal app that only shows up in certain locales (country/language combinations). Open Terminal in /Applications/Utilities and uncheck the box “Set locale environment variables on startup”.
This will set your LANG environment variable to be empty. This may cause terminal use to incorrect settings for your locale. The locale command in the Terminal will tell you what settings are used. To use the correct language, add a line to your bash profile (typically ~/.profile)
export LANG=your-lang
Replace your-lang with the correct locale specifier for your language. The command locale -a will show you all the specifiers. For example, the language code for US English is en_US.UTF-8. The locale affects what translations are used when they are available, and also how dates, currencies, and decimals are formatted.
Note, this image and content were taken from http://conda.pydata.org/docs/troubleshooting.html#unknown-locale (I'm also the original author of that page).
in iTerm going to the menu
Preferences -> Profiles -> Terminal -> (Environment)
and then unchecking
"Set locale variables automatically"
made this error go away.
As your LC_CTYPE is wrong, you should find out where that wrong value is set and change it to something like en_US.UTF-8.
This question already has answers here:
Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"
(6 answers)
Closed 6 years ago.
After installing the latest Mac OSX 64-bit Anaconda Python distribution, I keep getting a ValueError when trying to start the IPython Notebook.
Starting ipython works fine:
3-millerc-~:ipython
Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
But starting ipython notebook:
4-millerc-~:ipython notebook
Results in the ValueError (with traceback):
Traceback (most recent call last):
File "/Users/millerc/anaconda/bin/ipython", line 7, in <module>
launch_new_instance()
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 313, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/core/application.py", line 325, in initialize
self.parse_command_line(argv)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 308, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 420, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 352, in initialize_subcommand
subapp = import_item(subapp)
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/utils/importstring.py", line 40, in import_item
module = __import__(package,fromlist=[obj])
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookapp.py", line 46, in <module>
from .handlers import (LoginHandler, LogoutHandler,
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/html/notebook/handlers.py", line 36, in <module>
from docutils.core import publish_string
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
from docutils.io import FileOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Users/millerc/anaconda/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 503, in getdefaultlocale
return _parse_localename(localename)
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Running the locale command from the terminal:
5-millerc-~:locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
I summarize here the solution to be found on: http://blog.lobraun.de/2009/04/11/mercurial-on-mac-os-x-valueerror-unknown-locale-utf-8/
I added these lines to my .bash_profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
I reloaded the profile:
source ~/.bash_profile
I then ran ipython again:
ipython notebook
Changing locales
The above will work for the English language in a US locale. One may want different settings.
At the risk of stating the obvious, to discover the current settings for your system, use:
$ locale
And to retrieve a list of all valid settings on your system:
$ locale -a
Then choose your preferred locale. For example, for a Swiss French locale, the solution would look like this:
export LC_ALL=fr_CH.UTF-8
export LANG=fr_CH.UTF-8
This is a bug in the OS X Terminal app that only shows up in certain locales (country/language combinations). Open Terminal in /Applications/Utilities and uncheck the box “Set locale environment variables on startup”.
This will set your LANG environment variable to be empty. This may cause terminal use to incorrect settings for your locale. The locale command in the Terminal will tell you what settings are used. To use the correct language, add a line to your bash profile (typically ~/.profile)
export LANG=your-lang
Replace your-lang with the correct locale specifier for your language. The command locale -a will show you all the specifiers. For example, the language code for US English is en_US.UTF-8. The locale affects what translations are used when they are available, and also how dates, currencies, and decimals are formatted.
Note, this image and content were taken from http://conda.pydata.org/docs/troubleshooting.html#unknown-locale (I'm also the original author of that page).
in iTerm going to the menu
Preferences -> Profiles -> Terminal -> (Environment)
and then unchecking
"Set locale variables automatically"
made this error go away.
As your LC_CTYPE is wrong, you should find out where that wrong value is set and change it to something like en_US.UTF-8.