Error importing sdl2 in python3 - python

I have a file test.py which contains only the line "import sdl2". I am running Ubuntu and have installed libsdl2 from the official repos and installed pysdl2 from pip3. I get this error:
Traceback (most recent call last):
File "./test.py", line 2, in <module>
import sdl2
File "/usr/local/lib/python3.3/dist-packages/sdl2/__init__.py", line 11, in <module>
from .events import *
File "/usr/local/lib/python3.3/dist-packages/sdl2/events.py", line 5, in <module>
from .keyboard import SDL_Keysym
File "/usr/local/lib/python3.3/dist-packages/sdl2/keyboard.py", line 7, in <module>
from .video import SDL_Window
File "/usr/local/lib/python3.3/dist-packages/sdl2/video.py", line 256, in <module>
SDL_GL_ResetAttributes = _bind("SDL_GL_ResetAttributes")
File "/usr/local/lib/python3.3/dist-packages/sdl2/dll.py", line 84, in bind_function
(funcname, self._dll))
ValueError: could not find function 'SDL_GL_ResetAttributes' in <CDLL 'libSDL2-2.0.so.0', handle 1088720 at 7fdce18f5910>
My only thought is that possibly there's some version mismatch in packages? I couldn't find anything referencing this bug after a quick googling.

This is a bug in pysdl2, which indicates that your SDL2 library version is not the latest one. (2.0.3). It has been fixed in a recent commit: https://bitbucket.org/marcusva/py-sdl2/commits/03870c58615b115abf14b11056bbcd41652873c5

Related

import libusb "This OS is not supported yet!"

I have been trying to code the display on my Ableton push 2 with python using this guide: github.com/ffont/push2-python#using-the-simulator, but I ran into a problem with pyusb and i was missing libusb. pip3 kept saying I already had it installed but I still kept getting errors when trying to use Libusb. So i tried using homebrew and it installed it but I still keep getting errors when using libusb.
this is what my terminal looks like when trying to import:
>>> import libusb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/__init__.py", line 7, in <module>
from ._libusb import * ; del _libusb # noqa
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_libusb.py", line 29, in <module>
from ._platform import CFUNC
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_platform/__init__.py", line 33, in <module>
from ._osx import DLL_PATH, DLL, dlclose, CFUNC
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_platform/_osx/__init__.py", line 14, in <module>
raise NotImplementedError("This OS is not supported yet!")
NotImplementedError: This OS is not supported yet!

nrfutil changes python version mid-script

I'm using nrfutil in a shell script. It's failing with this error:
Traceback (most recent call last):
File "/usr/local/bin/nrfutil", line 6, in <module>
from nordicsemi.__main__ import cli
File "/Library/Python/2.7/site-packages/nordicsemi/__main__.py", line 57, in <module>
from nordicsemi.zigbee.prod_config import ProductionConfig, ProductionConfigWrongException, ProductionConfigTooLargeException
File "/Library/Python/2.7/site-packages/nordicsemi/zigbee/prod_config.py", line 41, in <module>
import yaml
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yaml/__init__.py", line 374
class YAMLObject(metaclass=YAMLObjectMetaclass):
It's starting in python 2.7, then it looks like its running "import yaml" from a 3.6 library.
Why would it do this? How do I prevent it?
Thanks
I had an old version of nrfutil. I upgraded, all is good

Upgrading to latest pip caused ValueError

The latest upgrade to pip (using Python 3.5) causes the following error to occur for any pip command:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip3.5", line 7, in <module>
from pip import main
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/index.py", line 29, in <module>
from pip.wheel import Wheel, wheel_ext
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/wheel.py", line 32, in <module>
from pip import pep425tags
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 214, in <module>
supported_tags = get_supported()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 162, in get_supported
arch = get_platform()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 119, in get_platform
major, minor, micro = release.split('.')
ValueError: not enough values to unpack (expected 3, got 2)
I'm even unable to upgrade or uninstall. What caused this and how can it be fixed?
I went ahead and edited
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py
at line 120.
Removed the micro value, and it now works again. Not sure what happened.

Installing PyObjC in 10.9.5 fails

I'm having a hard time installing PyObjC in mavericks. I read other discussions here too and used many different resources and still I get same error when I try to import. for example:
from AppKit import NSObject
gives me this in console:
/usr/local/Cellar/python/2.7.9/bin/python /Library/Python/2.7/site-packages/pyobjc_framework_Cocoa-3.1b1-py2.7-macosx-10.9-intel.egg/AppKit/__init__.py
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pyobjc_framework_Cocoa-3.1b1-py2.7-macosx-10.9-intel.egg/AppKit/__init__.py", line 9, in <module>
import Foundation
File "Foundation/__init__.pyc", line 9, in <module>
File "CoreFoundation/__init__.pyc", line 11, in <module>
File "CoreFoundation/_inlines.pyc", line 14, in <module>
File "CoreFoundation/_inlines.pyc", line 13, in __load
ImportError: 'CoreFoundation/_inlines.so' not found
What are your suggestions? Should I just delete all the modules and reinstall them. Has anyone been successful with the library in 10.9?
ps: I'm using Xcode 6.2
Thanks

PyOpenGL-accelerate + numpy

I'm installing MakeHuman on Debian, so all dependencies was set up, but when launching it's an error:
SYS.PLATFORM: linux2
PLATFORM.MACHINE: x86_64
PLATFORM.PROCESSOR:
PLATFORM.UNAME.RELEASE: 2.6.32.26
PLATFORM.LINUX_DISTRIBUTION: debian 6.0.6
NUMPY.VERSION: 1.6.2
OpenGL_accelerate module loaded
Using accelerated ArrayDatatype
Unable to load numpy_formathandler accelerator from OpenGL_accelerate
Unable to load registered array format handler numeric
Traceback (most recent call last):
File "makehuman.py", line 310, in <module>
main()
File "makehuman.py", line 300, in main
from mhmain import MHApplication
File "./core/mhmain.py", line 32, in <module>
import mh
File "./lib/mh.py", line 29, in <module>
from glmodule import updatePickingBuffer, grabScreen, hasRenderSkin, renderSkin
File "./lib/glmodule.py", line 33, in <module>
from OpenGL.GL import *
File "/usr/lib/python2.7/dist-packages/OpenGL/GL/__init__.py", line 3, in <module>
from OpenGL.raw.GL.annotations import *
File "/usr/lib/python2.7/dist-packages/OpenGL/raw/GL/annotations.py", line 40, in <module>
'v',
File "/usr/lib/python2.7/dist-packages/OpenGL/arrays/arrayhelpers.py", line 197, in setInputArraySizeType
function.setPyConverter( argName, asArrayTypeSize(type, size) )
File "arraydatatype.pyx", line 393, in OpenGL_accelerate.arraydatatype.AsArrayTypedSizeChecked.__init__ (src/arraydatatype.c:7688)
AttributeError: 'module' object has no attribute 'sizeof'
Does anyone solve problems with link PyOpenGL+ numpy?
fixed that on my system by issuing:
sudo easy_install -U PyOpenGL
Noting:
using Ubuntu 12.04 LTS, with python2.7
did get a Permission denied error without that leading 'sudo'
via: http://matthew-4gl.wikispaces.com/python_modules ( in turn from https://bitbucket.org/ompl/ompl/issue/59/problem-with-ompl_apppy )
good luck

Categories

Resources