Python kivy and Linux Mint compatibility issue - python

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.

Related

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.

Py2App>0.13 always outputs ValueError/ Py2App v0.13 App not opening on second machine

So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.)
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 355, in <module>
_run()
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 340, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/dist/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 9, in <module>
from pysine import sine
File "pysine/__init__.pyc", line 14, in <module>
File "pysine/pysine.pyc", line 1, in <module>
File "pyaudio.pyc", line 116, in <module>
ImportError: dlopen(/Volumes/dist/Riff Gen.app/Contents/Resources/lib/python3.6/lib-dynload/_portaudio.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib
A simple tkinter test with various sounds and images works fine on the second machine, but not this script. I've tried adding all the packages manually, tried --nostrip, manually including 'libportaudio.2.dylib', and dozens of other ideas from countless outdated forums to no avail.
When the play function of my application is stripped, the app opens and crashes shortly thereafter - giving me the following error:
Traceback (most recent call last):
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 81, in <module>
_run()
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 66, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 2037, in <module>
root.mainloop()
File "tkinter/__init__.pyc", line 1277, in mainloop
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Fatal Python error: PyEval_RestoreThread: NULL tstate
Current thread 0x00007fffa118e380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.
[Process completed]
I have been using Python 3.6 and Py2App v0.13 because it is, unfortunately, the only version that has successfully packaged my program in a standalone package. Any version later than 0.13 gives me the following error even when bundling in alias mode:
Traceback (most recent call last):
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 420, in <module>
_run()
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 414, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/riffgen_v1.01.py", line 7, in <module>
from tkinter import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
I've seen a handful of people with similar errors to the one above, but the few solutions I've seen had no success.
I'm assuming there is a simple solution to both of these errors, but after a long two weeks of tinkering, I'm out of ideas. I just began programming and really want to continue to deploy GUI programs, so I am desperate to get this functional. Any help is greatly appreciated!!
Probably not an answer you were hoping for, but this might give you some ideas where to look:
check if you don't have multiple pythons installed. Make sure you run it with 3.6. (but you probably already did)
Check the modules installed on both PC's help('modules') in a python shell.
Check if the correct version of the modules is installed. Install the exact same versions pip install SomePackage==1.0.4
Symbol not found: ____chkstk_darwin seems to be a very mac related issue. I'd start searching there in combination with the modules you use in your script. This is the only post I found on stackoverflow and it suggests looking at the PATH settings; plaidml-setup uses the wrong lib path and gets OSErrors

Python3 and Pyglet - help needed

I am a newbie of Python and Pyglet. I just installed Pyglet on my Linux and Window7. I run a very simple test file on my Linux, I got errors
(On linux: Python 3.5.2 Pyglet 1.2.4)
The following is the test file-tests.py:
import pyglet
window = pyglet.window.Window()
pyglet.app.run()
I got the following errors when I run it on my Linux:
Traceback (most recent call last):
File "/home/work/.local/lib/python3.5/site-packages/pyglet/init.py", line 351, in getattr return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'Window'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "test.py", line 6, in <module> window = pyglet.window.Window() File "/home/work/.local/lib/python3.5/site-packages/pyglet/init.py", line 357, in getattr import(import_name)
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/init.py", line 1816, in <module> gl._create_shadow_window()
File "/home/work/.local/lib/python3.5/site-packages/pyglet/gl/init.py", line 205, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False)
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 163, in init super(XlibWindow, self).init(args, *kwargs)
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/init.py", line 558, in init self._create()
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 353, in _create self.set_caption(self._caption)
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 513, in set_caption self._set_text_property('_NET_WM_NAME', caption)
File "/home/work/.local/lib/python3.5/site-packages/pyglet/window/xlib/init.py", line 783, in _set_text_property raise XlibException('Could not create UTF8 text property')
pyglet.window.xlib.XlibException: Could not create UTF8 text property*
This test file works ok on my Win7
(On Window7: Python 3.6.0 Pyglet 1.2.4)
Please help if you know why. Thanks.
As we figured out from the comments above, it looked like the installation output printed some odd symbols. That and the fact that pyglet had problem loading UTF-8 context lead me to believe that there were no UTF-8 support generated in the OS.
Usually, you can uncomment en_US.UTF-8 in /etc/locale.conf and run locale-gen and that should solve the problem.
in your terminal
write LANG=en_US
Run your python code from the terminal
another solution by placing it before everything of your code
import os
os.environ['LANG']='en_US'
edit your /etc/default/locale, and try to feed all locale critiria as the same:
# File generated by update-locale
LANG=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=en_US.UTF-8
Use sudo dpkg-reconfigure locales to set your own language. Make sure to mark en_US.UTF-8 selection.
sudo locale-gen en_US en_US.UTF-8
Reboot

python pyglet and opengl

I am trying to get 3D capabilities through python and have download pyglet. While going through the first example in this tutorial I got a bunch of strange errors that I cannot discern. The following is the script I am trying to run:
import pyglet
win = pyglet.window.Window()
#win.event
def on_draw():
win.clear()
pyglet.app.run()
2 The following is the output I received from the python interpreter after I imported my script:
>>> import test as t
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 13, in <module>
pyglet.app.run()
File "/usr/lib/pymodules/python2.7/pyglet/app/__init__.py", line 264, in run
EventLoop().run()
File "/usr/lib/pymodules/python2.7/pyglet/app/xlib.py", line 93, in run
sleep_time = self.idle()
Fihttp://greendalecs.wordpress.com/2012/04/21/3d-programming-in-python-part-1/#commentsle "/usr/lib/pymodules/python2.7/pyglet/app/__init__.py", line 193, in idle
window.dispatch_event('on_draw')
File "/usr/lib/pymodules/python2.7/pyglet/window/__init__.py", line 1219, in dispatch_event
EventDispatcher.dispatch_event(self, *args)
File "/usr/lib/pymodules/python2.7/pyglet/event.py", line 340, in dispatch_event
if handler(*args):
File "test.py", line 13, in on_draw
pyglet.app.run()
NameError: global name 'GL_COlOR_BUFFER_BIT' is not defined
How can I fix these errors? I use Ubuntu 12.04 LTS and Emacs 24.3.
I have downloaded pyglet, through apt-get install but is there anything else I needed to do? Perhaps I do not have drivers configured or I need different software.
If you need more information let me know!
GL_COlOR_BUFFER_BIT is undefined, because the value you are looking for is called GL_COLOR_BUFFER_BIT...
For future reference, as of Pyglet 1.1.4, this is because 1.1.4 no longer supports "recent" versions of Mac OS.
However, the most recent non-released version of Pyglet DOES support, with a full new interface using Cocoa. So, until Pyglet 1.2 is released, you have to install Pyglet directly from the trunk, using e.g.
pip install --upgrade http://pyglet.googlecode.com/archive/tip.zip

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