• Register
0 votes
622 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

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 1
3,890 points

Related questions

0 votes
1 answer 334 views
334 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 202 views
202 views
Problem: I have recently started learning Python so I have only fundamental knowledge in Python. Please find below my Transaction class for your reference: class Transaction(object):     def __init__(self, company, num, price, date, is_buy):         self.company = company         ... Python and because of lockdown I am unable to find any help to fix this issue. So I am posting my question here.
asked Aug 10 Raphael Pacheco 4.9k points
1 vote
1 answer 100 views
100 views
Problem: I am getting an interesting error: valueerror: mixing iteration and read methods would lose data while I’m trying to run my script on python. I have no idea about this problem. I am trying to open a text file in my program and read it. Please ... test_file I think I am doing something wrong with using the readline() function. I am looking forward to having a solution. Thanks, guys.
asked Mar 29 Gavin 15.3k points
0 votes
1 answer 86 views
86 views
Problem : I am unable to understand what am I missing here: Sort my_short_names in reverse alphabetic order. The sample output from the given program as below : ['Tody', 'Samy', 'Joey', 'Jany', 'Anny'] Below is my code for your reference : my_short_names = ['Jany', 'Samy', 'Anny', 'Joey', 'Tody'] my_short_names.sort() print(my_short_names)
asked Jan 8 alecxe 7.5k points
0 votes
1 answer 261 views
261 views
Problem : I am trying to execute below commands. import numpy as np import cv But I am getting following error on my console: >>> runfile('/Users/isaiahnields/.spyder2/temp.py', wdir='/Users/isaiahnields/.spyder2') RuntimeError: module compiled against API version a but this ... it is not working. I had added cv.py to the python2.7 folder in Spyder-Py2 is there anything else I need to add?
asked Dec 4, 2019 alecxe 7.5k points