Python bus error destroy python environment - python

I am running python 3.7 using anaconda installation on ubuntu 16 virtual machine. Due to some extensive pandas merges my machine runes out the memory what is causing bus error (why not memory exception).
But after that crash, my python installation is corrupted. It looks like random python files (like site.py) are modified.
The problem occurs each time in a different way. I have also tried to change the mode during the execution of anaconda directory to 000 and files also looked corrupted. Any help or root cause?
One of the failure:
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site.py", line 579, in
main()
File "/opt/anaconda3/lib/python3.7/site.py", line 566, in main
known_paths = addsitepackages(known_paths)
File "/opt/anaconda3/lib/python3.7/site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "/opt/anaconda3/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/opt/anaconda3/lib/python3.7/site.py", line 163, in addpackage
for n, line in enumerate(f):
File "/opt/anaconda3/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 1: invalid continuation byte

Related

Anaconda prompt fail to launch: UnicodeEncodeError: 'utf-8' codec can't encode character '\udd8e': surrogates not allowed

I have Windows 10 x64 en-US and Anaconda3 2021.05. My anaconda prompt was working. Today it failed to launch and shows an error:
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 140, in main
return activator_main()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 1210, in main
print(activator.execute(), end='')
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 178, in execute
return getattr(self, self.command)()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 153, in activate
return self._finalize(self._yield_commands(builder_result), self.tempfile_extension)
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 143, in _finalize
tf.write(self.command_join.join(commands))
File "C:\ProgramData\Anaconda3\lib\tempfile.py", line 473, in func_wrapper
return func(*args, **kwargs)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udd8e' in position 952: surrogates not allowed
`$ C:\ProgramData\Anaconda3\Scripts\conda-script.py shell.cmd.exe activate C:\ProgramData\Anaconda3`
Anaconda PowerShell Prompt also fails to launch with similar error:
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 140, in main
return activator_main()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 1210, in main
print(activator.execute(), end='')
UnicodeEncodeError: 'utf-8' codec can't encode character '\udd8e' in position 954: surrogates not allowed
`$ C:\ProgramData\Anaconda3\Scripts\conda-script.py shell.powershell activate C:\ProgramData\Anaconda3`
I searched around and tried everything, including:
Uninstall and reinstall Anaconda.
Upgrade Python to the latest version.
Add PYTHONIOENCODING=utf8 to environment variables.
Add "C:\ProgramData\Anaconda3" and "C:\ProgramData\Anaconda3\Scripts" to PATH.
Removing tempfile.py.
etc., couldn't fix it.
I searched this \udd8e character:
This is an unassigned character within a valid range, meaning it could be designated a valid Unicode code point in the future. However, for now it has no assigned value.
How could I fix this? Thank you very much.
The issue is a non-unicode letter in you PATH environment, which has to be deleted.
Go to your PATH environment file (control panel > system > advanced settings > environment variables) and delete paths under your local user account with non-unicode letters in it.
I had a similar error where setting the PYTHONIOENCODING=utf8 environment variable didn't work, but setting PYTHONUTF8=1fix it.

UnicodeDecodeError when trying to open Idle for Python 3.8

I tried launching idle on the command prompt by using python -i -m idlelib
This the error that occurred:
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\site.py", line 580, in <module>
main()
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\site.py", line 567, in main
known_paths = addsitepackages(known_paths)
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\site.py", line 350, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\site.py", line 208, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\site.py", line 164, in addpackage
for n, line in enumerate(f):
File "C:\Users\_\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 654: character maps to undefined
Try python -i first and see if you can access the idle on the console.
Once you've verified that, you should then open idle on your pc and try import idlelib. If it doesn't load that means that either you don't have that module or its not in you path (which you can fix by finding its location and running import sys; sys.path.append("path/to/module")).
My guess would be that you have multiple versions of python on your pc and when you're running python you are not using the version that has this module.
A person here seems to have had a similar problem, albeit with a different program where the environmental variables they used caused problems. I recommend getting a package like conda. That'll reduce the likelihood of running into these problems immensely.

Python kivy and Linux Mint compatibility issue

I have several programs written in python and kivy language, all of them written in windows environment and working properly. When I tried to run them in Linux Mint, i get a "UnicodeDecodeError". This happens only to the programs that import kivy and it's modules, while all my other python programs work fine. So i wrote a simple kivy program in Linux Mint to see if there is a problem with being written in Win10 and still I get the same error. I've looked it up and saw that others too have similar issues but not the same so i couldn't find an answer to fit my needs.
my releases are: Python 3.4.0 | Kivy 1.9.1 | Linux Mint 17.2 Cinnamon 64bit
Here's my program written in Linux Mint environment:
from kivy.app import App
from kivy.uix.label import Label
class mylabel(App):
def build(self):
return Label(text="Linux Mint!")
if __name__ == "__main__":
mylabel().run()
And here's the error:
Traceback (most recent call last):
File "mintkivy.py", line 9, in <module>
mylabel().run()
File "/usr/lib/python3/dist-packages/kivy/app.py", line 828, in run
runTouchApp()
File "/usr/lib/python3/dist-packages/kivy/base.py", line 451, in runTouchApp
p = provider(key, args)
File "/usr/lib/python3/dist-packages/kivy/input/providers/probesysfs.py", line 155, in __new__
instance.__init__(device, args)
File "/usr/lib/python3/dist-packages/kivy/input/providers/probesysfs.py", line 192, in __init__
self.probe()
File "/usr/lib/python3/dist-packages/kivy/input/providers/probesysfs.py", line 213, in probe
device.name, device.device))
File "/usr/lib/python3/dist-packages/kivy/input/providers/probesysfs.py", line 80, in name
return read_line(path)
File "/usr/lib/python3/dist-packages/kivy/input/providers/probesysfs.py", line 145, in read_line
return f.readline().strip()
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 19: ordinal not in range(128)
p.s. I have installed kivy in Linux and after i got the problem i added it in the PyCharm compiler too, and they both produce the same error.
I appreciate the help. Thank you.

Django python manage.py collectstatic UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 32: ordinal not in range(128)

My problem is the following:
When I'm running python manage.py collectstatic inside of my Django-project I'm getting this error:
/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py:302: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return name == ":memory:" or "mode=memory" in force_text(name)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 151, in handle
message.append(':\n\n %s\n\n' % destination_path)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 32: ordinal not in range(128)
I somewhat know, why it occurs but I'm not able to fit it. (Maybe because I didn't want to break any Django files...)
If you need some more Information I'll happily give it to you.
Thanks.
It works for me export in console.
1º
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
2º
python manage.py collectstatic
check over django-pipeline/issues

How to run Google app engine web server on Windows correct?

I tried to run Google App Engine development server using Python 3.2 and Python 2.7, got errors on both:
Python 2.7:
D:\nCdy\WA>C:\Python27\python.exe "D:\Program Files\Google\google_appengine\dev_
appserver.py" wa.py
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\dev_appserver.py", line 76, in
<module>
run_file(__file__, globals())
File "D:\Program Files\Google\google_appengine\dev_appserver.py", line 72, in
run_file
execfile(script_path, globals_)
File "D:\Program Files\Google\google_appengine\google\appengine\tools\dev_apps
erver_main.py", line 156, in <module>
from google.appengine.tools import dev_appserver
File "D:\Program Files\Google\google_appengine\google\appengine\tools\dev_apps
erver.py", line 179, in <module>
mimetypes.add_type(mime_type, '.' + ext)
File "C:\Python27\lib\mimetypes.py", line 344, in add_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
Python 3.2:
D:\nCdy\WA>C:\Python32\python.exe "D:\Program Files\Google\google_appengine\dev_
appserver.py" wa.py
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\dev_appserver.py", line 76, in
<module>
run_file(__file__, globals())
File "D:\Program Files\Google\google_appengine\dev_appserver.py", line 72, in
run_file
execfile(script_path, globals_)
NameError: global name 'execfile' is not defined
How do I run it?
It won't work with Python 3.2.
I've had no trouble with GAE and Python 2.7 on Windows 7. It will soon be the officially supported version.
Right now, the officially supported version is Python 2.5, so you should download that if you have any problems getting other versions to work.
I'd suggest something like ActiveState since there are no official binaries for the latest version of Python 2.5.
check this.
UnicodeDecodeError : 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
I have absolutely the same problem as you, and the problem was bad names (in may case - cyrillic names) in registry over here HKEY_CLASSES_ROOT\MIME\Database\Content Type
As agf mentioned, the problem is you're running the GAE test server with python 3.2 instead of 2.7. To fix this you have a few options:
Specify the python interpreter you want at the command line (eg make a .cmd file):
c:\python27\python dev_appserver.py project_dir
Or redefine the python default interpreter which can either be done by changing the .py handler in "set default programs". Modifying the path environment variables can help as well.

Categories