1

I am a novice and picking up DS using python. I used the latest Anaconda package and tried to import pandas in Jupyter. Then I encountered following error message. I tried to install Pandas package again with conda command but it didn't resolve this issue. Thanks for any advice in advance.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd

//anaconda/lib/python2.7/site-packages/pandas/__init__.pyc in <module>()
     37 import pandas.core.config_init
     38 
---> 39 from pandas.core.api import *
     40 from pandas.sparse.api import *
     41 from pandas.stats.api import *

//anaconda/lib/python2.7/site-packages/pandas/core/api.py in <module>()
      8 from pandas.core.common import isnull, notnull
      9 from pandas.core.categorical import Categorical
---> 10 from pandas.core.groupby import Grouper
     11 from pandas.formats.format import set_eng_float_format
     12 from pandas.core.index import (Index, CategoricalIndex, Int64Index,

//anaconda/lib/python2.7/site-packages/pandas/core/groupby.py in <module>()
     16                               DataError, SpecificationError)
     17 from pandas.core.categorical import Categorical
---> 18 from pandas.core.frame import DataFrame
     19 from pandas.core.generic import NDFrame
     20 from pandas.core.index import (Index, MultiIndex, CategoricalIndex,

//anaconda/lib/python2.7/site-packages/pandas/core/frame.py in <module>()
     37                                    create_block_manager_from_arrays,
     38                                    create_block_manager_from_blocks)
---> 39 from pandas.core.series import Series
     40 from pandas.core.categorical import Categorical
     41 import pandas.computation.expressions as expressions

//anaconda/lib/python2.7/site-packages/pandas/core/series.py in <module>()
   2942 # Add plotting methods to Series
   2943 
-> 2944 import pandas.tools.plotting as _gfx  # noqa
   2945 
   2946 Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods,

//anaconda/lib/python2.7/site-packages/pandas/tools/plotting.py in <module>()
     25 from pandas.util.decorators import Appender
     26 try:  # mpl optional
---> 27     import pandas.tseries.converter as conv
     28     conv.register()  # needs to override so set_xlim works with str/number
     29 except ImportError:

//anaconda/lib/python2.7/site-packages/pandas/tseries/converter.py in <module>()
      5 from dateutil.relativedelta import relativedelta
      6 
----> 7 import matplotlib.units as units
      8 import matplotlib.dates as dates
      9 

//anaconda/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
   1129 
   1130 # this is the instance used by the matplotlib classes
-> 1131 rcParams = rc_params()
   1132 
   1133 if rcParams['examples.directory']:

//anaconda/lib/python2.7/site-packages/matplotlib/__init__.py in rc_params(fail_on_error)
    973         return ret
    974 
--> 975     return rc_params_from_file(fname, fail_on_error)
    976 
    977 

//anaconda/lib/python2.7/site-packages/matplotlib/__init__.py in rc_params_from_file(fname, fail_on_error, use_default_template)
   1098         parameters specified in the file. (Useful for updating dicts.)
   1099     """
-> 1100     config_from_file = _rc_params_in_file(fname, fail_on_error)
   1101 
   1102     if not use_default_template:

//anaconda/lib/python2.7/site-packages/matplotlib/__init__.py in _rc_params_in_file(fname, fail_on_error)
   1016     cnt = 0
   1017     rc_temp = {}
-> 1018     with _open_file_or_url(fname) as fd:
   1019         try:
   1020             for line in fd:

//anaconda/lib/python2.7/contextlib.pyc in __enter__(self)
     15     def __enter__(self):
     16         try:
---> 17             return self.gen.next()
     18         except StopIteration:
     19             raise RuntimeError("generator didn't yield")

//anaconda/lib/python2.7/site-packages/matplotlib/__init__.py in _open_file_or_url(fname)
    998     else:
    999         fname = os.path.expanduser(fname)
-> 1000         encoding = locale.getdefaultlocale()[1]
   1001         if encoding is None:
   1002             encoding = "utf-8"

//anaconda/lib/python2.7/locale.pyc in getdefaultlocale(envvars)
    541     else:
    542         localename = 'C'
--> 543     return _parse_localename(localename)
    544 
    545 

//anaconda/lib/python2.7/locale.pyc in _parse_localename(localename)
    473     elif code == 'C':
    474         return None, None
--> 475     raise ValueError, 'unknown locale: %s' % localename
    476 
    477 def _build_localename(localetuple):

ValueError: unknown locale: UTF-8
Ghostintheshell
  • 163
  • 2
  • 7

1 Answers1

0

If you are using Mac OS X, try adding the following lines to your ~/.bash_profile:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Stefan
  • 41,759
  • 13
  • 76
  • 81
  • Thanks for the tips. But I can't locate this bash_profile when i type that in spotlight. Sorry, I am no programmer and this is foreign to me. – Ghostintheshell May 30 '16 at 11:50
  • Should be in your `home` directory, the one that has your user name. It may not exist yet - here's an explanation of how to create one: https://natelandau.com/my-mac-osx-bash_profile/ – Stefan May 30 '16 at 11:55
  • Were you able to resolve the issue? – Stefan May 31 '16 at 12:37
  • Yes, I got it handled. Many many thanks. Interesting to note. That only happens on my Macbook, not my Macbook Pro. Both are using El Captain system and updated to the latest version of Anaconda. But somehow they performed differently and the pandas version is different as I recalled. I don't know why. Is that a problem because I installed some non-conda package like mlestack, PyMC, etc using pip. And I also have Canopy version of Python installed. I am just baffled by their different performance. – Ghostintheshell May 31 '16 at 14:27
  • It pays to get familiar with `bash`, the `Terminal` app. The `Mac OS` accesses python versions based on a `PATH` variable that you can also set in `.bash_profile`. If you as `which python` in `Terminal`, you'll see which `python` version the system will access first. If you have `pip` installed, you can also do `pip freeze` to see the current list of packages and versions. Take a look at `homebrew` to install software other than python packages, and at `virtual environment` to manage python installations. – Stefan May 31 '16 at 14:54
  • Thanks for all the tips and I really have to check out and understand everything you mentioned here. So, what you are trying to say is even I installed many different libraries that may or may not be handled by Conda I can still set up path at bash file so that my juypter notebook under the anaconda folder can still access. Is that the gist? Now I regret that I should study CS instead of business admin. – Ghostintheshell Jun 03 '16 at 16:08
  • Anaconda usually modifies the `PATH` so that the system considers it the first `python` to look for, and `pip install` will install under anaconda python, so your packages should be available. `which python` in terminal will tell you which `python` installation the system looks for first. If that is not the one you want to use, you need to modify `PATH` in your `.bash_profile`. This is all separate from your original question on the language settings, though. – Stefan Jun 03 '16 at 16:14
  • Got it. Will try out when I am working on my ML exercise next time. Many thanks for all the tips. – Ghostintheshell Jun 04 '16 at 13:08