I installed anaconda by running the
bash Anaconda-2.2.0-Linux-x86_64.sh
command on my Ubuntu 14.04 system , which installed successfully, after which I was asked to export my new /home/username/anaconda/bin
$PATH environment variable.
On doing so, I was able to use all of anaconda's features including the IDE's as well as use all conda based commands successfully.
The next time I booted up my system, every miss-typed command saw a
Fatal Python error: Py_Initialize: Unable to get the locale encoding
File "/usr/local/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Aborted (core dumped)
error. (All commands except python
to be specific)
On following a few stackexchange and askubuntu posts and also noticing that my $PYTHONPATH
had been set to usr/local/lib/python2.7
, I tried to
export PYTHONPATH=$PYTHONPATH:/home/username/anaconda/lib/python2.7
but it didn't help.
This had me go through a entire saga of package removals and reinstalls, and of course, a lot of updates and upgrades, to try and fix the problem by myself.
conda info -a
returns:
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: <not set>
CONDA_ENVS_PATH: <not set>
LD_LIBRARY_PATH: <not set>
PATH: /home/username/anaconda/bin:/home/username/Scala-sbt/sbt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/username/bin:/usr/local/java/jdk1.8.0_20/bin
PYTHONHOME: <not set>
PYTHONPATH: /usr/local/lib/python2.7:/home/username/anaconda/bin/python
The command
which python
returns
/home/username/anaconda/bin/python
and
echo "$PATH"
returns
/home/username/anaconda/bin:/home/username/Scala-sbt/sbt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/username/bin:/usr/local/java/jdk1.8.0_20/bin
I know it's something to do with the way I set the path variables, specifically in the ~/.bashrc
in which Anaconda automatically prepended my /home/username/anaconda/bin folder to the $PATH
variable (This happened during a second installation of Anaconda after I removed it first).
I haven't modified any other environment variable in either ~/.profile
or ~/.bashrc
.
I added the export $PYTHONPATH line to my ~/.bashrc
before restarting.
All of Anaconda's features work now, although the same Fatal Python error: Py_Initialize: Unable to get the locale encoding
error keeps showing up instead of the usual unknown command error, for most mistyped commands.
I will keep looking into this and edit my answer (or refer to existing answers, if any) as soon as I find out why this happens.