• Register
0 votes
974 views

Problem :

On installing Anaconda on Ubantu getting below Python error on miss-typed commands
fatal python error: py_initialize: unable to get the locale encoding
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution:

I have also faced similar issues in the past , so I traced it back to how bash handles "command not found". In Ubuntu 14.04 

/etc/bash.bashrc has the following function:

if [ -x /usr/lib/command-not-found ]; then
    function command_not_found_handle {
        # check because c-n-f could've been removed in the meantime
        if [ -x /usr/lib/command-not-found ]; then
            /usr/bin/python /usr/lib/command-not-found -- $1
            return $?
        else
           return 127
        fi
    }
fi

Further Readings:

https://github.com/GrahamDumpleton/mod_wsgi/issues/336

9 7 4
38,600 points
0 votes

It is suggested to use PYTHONPATH. Mostly it is not needed and causes many things to break like this by making one Python load things form another Python.

Reason:

 When you try to execute the command in python 3.5. Then the error message can occur;

Fatal Python error: Py_Initialize: Unable to get the locale encoding

InmportError: No module named ‘encodings’

Current thread 0x00007ff41bf46700 (most recent call first):

Aborted (core dumped)

What could be the problem?

How to fix- Fatal Python error: Py_Initialize: Unable to get the locale encodings

ImportError: No module named ‘encodings’

Solution:

This error can be due to multiple installations on your machine and the command python3.5 might be referring to libraries that belong to different versions of Python. There can be another reason “The command python3.5 is not able to find the PYTHON installation path.

Use the below lines to solve the error:

export PYTHONPATH = /usr/local/lib/python3.5

export PYTHONPATH = /usr/local/lib/python3.5

Note:

Make sure that you have set the correct installation path of Python3.5.

Python 3.5.9 (default, Nov 6 2015, 16:57;04)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-11) on Linux

Type “help”, “copyright”, “credits”, or “license” for more information.

>>> 

 

11 5 2
3,890 points

Related questions

0 votes
1 answer 32 views
32 views
Problem: I am attempting to put together a simple c++ test project that uses an embedded python 3.2 interpreter. The project builds fine but Py_Initialize raises a fatal error: Fatal Python error: Py_Initialize: unable to load the file system codec LookupError: no codec search functions registered: can't find encoding
asked Feb 15 Mashhoodch 13k points
0 votes
1 answer 4 views
4 views
Problem: I was trying a simple piece of code, get someone's name and age and let him/her know when they turn 21... not considering negatives and all that, just random. I keep getting this 'int' object is not subscriptable error. Error: 'int' object is not subscriptable
asked Mar 31 ummesalma 25.2k points
0 votes
1 answer 79 views
79 views
Problem: error: (-215:assertion failed) !empty() in function 'cv::cascadeclassifier::detectmultiscale'
asked Feb 19 Lucky Guy 1.5k points
0 votes
1 answer 3 views
3 views
Problem: How to add 50 to the number stored under the 'gold' key?
asked 3 days ago ummesalma 25.2k points
0 votes
1 answer 466 views
466 views
Problem : When I executed: pip install xgboost I got this: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/w4/w49s3mn91plbhyjwf8qjkpxc0000gn/T/pip-build-61dms1/xgboost/
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 2 views
2 views
Problem: I'm a complete noob when it comes to programming and having an issue with python maths. If I run the following line of code, python returns 97 as the answer.
asked 3 days ago ummesalma 25.2k points
0 votes
1 answer 3 views
3 views
Problem: Why does Python 2 evaluate to 7 and Python 3 evaluate to 6.75? How does Python arrive at the result
asked 4 days ago ummesalma 25.2k points
0 votes
1 answer 14 views
14 views
Problem: I need someone’s help to fix it... an example of an attribute of an object might be
asked Mar 31 Ifra 24.4k points
0 votes
1 answer 4 views
4 views
Problem: Please help me … how can I solve it? runtimewarning: invalid value encountered in divide
asked Mar 22 Ifra 24.4k points
0 votes
1 answer 9 views
9 views
Problem: In Python I'm getting an error: Str' object has no attribute 'read' What does this error mean and what did I do to cause it?
asked Mar 22 ummesalma 25.2k points