• Register
0 votes
433 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.9k points
edited by

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

36.1k points
edited by
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.

>>> 

 

3.9k points

Related questions

0 votes
1 answer 254 views
254 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
1 vote
1 answer 44 views
44 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.2k points
0 votes
1 answer 70 views
70 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 168 views
168 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
0 votes
1 answer 596 views
596 views
Problem : I am using the sqlite3 to store the values into database, My problem is that I have created lineedits through which I am trying to extract values and store it to the variables and pass this variables to the insert query but i am facing below error at line values(?, ... ?,?,?)''',(self.uname,self.passwd,self.permssn)) print ('inserted row') self.createDb.commit() Any solution on my error?
asked Jan 18 jwilliam 3.9k points