OpenAL Python openal.audio module not found - python

I was trying to do some work in Python with simulating 3D sound. I was trying to run this code (provided in the answer): Python openAL 3D sound and similar, both times receiving:
ModuleNotFoundError: No module named 'openal.audio'
I've installed OpenAL, PyAL, and tried installing an older version (uninstalled it and reinstalled the new one), but it still doesn't work.
I've also tried the following code:
from openal import *
class AudioSource:
def __init__(self, path_to_file):
self.src = oalOpen(path_to_file)
def play(self):
self.src.play()
self.src.position = (-100, 0, 0)
self.src.update()
which doesn't use the openal.audio package, but the position doesn't seem to have any effect on the sound source either. I'm open to any solution (including using a newer package if one is available that will produce 3D sound)

Using link to python OpenAL library at https://bitbucket.org/marcusva/py-al/downloads/
just download either the tar.gz or other one then once expanded it gives you dir something like
~/src/PyAL-0.1.0/
then type
make
if no errors there to install issue
make install
sudo make install # this works on ubuntu ... dunno about Windows or osx
then to kick tires run the provided example
cd ~/src/PyAL-0.1.0/examples/
python ./player.py
which is a rather nice 3D audio demo ... now your python import openal will work ... I confirmed this by running another script at https://stackoverflow.com/a/40945609/147175
If this still goes pear shaped what OS are you on ?

Related

install opencv from source windows

I am trying to install OpenCV following this link https://docs.opencv.org/master/d5/de5/tutorial_py_setup_in_windows.html
opencv-4.5.1 is the version I am building from source. I have no errors in my entire process( up to Step 16)
Step 17 which INSTALL also has no errors, but Step 18 'import cv2 as cv' will not import this module.
I have python 3.9.1. I followed all the steps with CMAKE and was able to generate with no errors.
Is there something that I am missing here?
I would recommend to use another IDE like Pycharm to create your projects. It is extremely easy to setup an OpenCV work environment :).
IDLE is great for smaller projects but I`ve seen a lot of people having issues with it.

Python PIP Install on Windows missing sub-directories?

My 11-year-old son is trying to follow Carol Vorderman's "Python Games for Kids" book, but is hitting a fundamental problem installing then using Actors module (p.52-onwards of book), on Windows 10. No instructions are provided for installing or importing this. We installed 'actors' (0.5.1b1) using pip:
pip install actors
The install "works" happily, no error is reported, and a (basic) actors installation appears. (We also tried python -m pip install actors, with exactly the same result).
However, any attempt to import actors; e.g.,
from actors import Actor
fails with:
ModuleNotFoundError: no module name 'actors.internal'
of line 29 of actors\__init__.py . Which is fair enough, because it does try to import messages from actors.internal, which does not seem to exist.
Things I checked following the import:
the downloaded .tar.gz file includes a load of subdirectories, including internal; but this doesn't make it into the disc. So it looks like pip isn't handling the .tar.gz file correctly? But it seems hard to believe that such a basic failure has gone undetected.
the disc has 116G free, so it's not running outta space.
I checked other answers (python pip install not working on windows, pip install on a shared directory (windows)), but they do not seem to apply here.
This is a bug in the distribution. It lists packages=['actors'], but it must list all subpackages (internal and utils) too.
The bug was reported in 2016 and still is unresolved. So we can guess the package is abandoned and there is not much you can do to fix it (other than forking and fixing it yourself).
You need to run your program through Pygame Zero, since it adds a few things for you (like opening a window, handling OS events, defining what an Actor or a Sprite are, etc).
Install it with: pip install pgzero
And then instead of running your file normally via python my_file.py
You should run it with: pgzrun my_file.py
If that doesn't work you can try putting import pgzrun on first line of the program and pgzrun.go() on the last line and then running the file normally with: python my_file.py.
Source for the fixes

Where to put the unreal engine python library for pylint

I'm playing around with the Unreal Engine 4 and the python plugin. Adding it and getting it to work is no problem (win64, python 3.6.5 64bit) but since almost every py file for unreal starts out with import unreal_engine and I don't have that installed to the system like I would with something from pip install I'm wondering where to put what part of that repo so I don't have the pylint error [pylint] E0401:Unable to import 'unreal_engine' and lots of other "errors" like the following:
class Hero:
# this is called on game start
def begin_play(self):
self.startZ = self.uobject.get_actor_location().z
the last line with self. presents a linter error of [pylint] E1101:Instance of 'Hero' has no 'uobject' member.
Again I want to stress that all the code works inside of Unreal but it would be really nice to have the IDE pick the classes up right so I also get the autocomplete suggestions for available methods on uobject.something.
I'm fairly new to python programming and only ever had to import system libraries or things installed via pip so this is confusing to me.
For reference I have installed python via the official python installer for Windows to c:\dev\Python\Python36. The bin folder is in windows PATH and all that fun stuff.

how to import cv2 and numpy in Choregraphe for NAO robot?

I'm doing a project that require cv2 and numpy in one of the scripts using choregraphe, but I get an error :
No module named cv2/numpy.
I think it is because choregraphe has its own python interpreter but I do not know how to install cv2 and numpy into the python of choregraphe.
How can I do it?
It depends if you're using a real NAO or a simulated one.
Simulated one: choregraphe use its own embedded python interpreter, even if you add library to your system it won't change anything
Real NAO: the system python interpreter is used, you need to install those library to your robot (and not to the computer running choregraphe). As pip ofthen doesn't work fine in NAO, you'll have to manually copy library to /home/nao/.local/lib/python2.7/site-packages
first do a pip install <lib or package> --target=<location in your local hard drive>
make a folder inside your choregraphe project named 'lib'
Copy the package inside that folder lib.
Create a box and put this on root.
do something like this
def __init__(self):
GeneratedClass.__init__(self)
self.path = ALFrameManager.getBehaviorPath(self.behaviorId) + "/lib"
if self.path not in sys.path:
sys.path.append(self.path)
the intent of this is to have your local folder lib be pointed to where python looks for libraries.
Now you can do the normal way of importing your python libraries

extract single frame from video

I am trying to write a script that will extract a single frame from a user uploaded video clip in order to create a thumbnail. It sounds like either OpenCV or ffmpeg will do what I need, but I am having trouble installing them.
I tried installing OpenCV using apt-get install libopencv-dev, and it looks like everything worked, but when running import cv2 in Python, it says there is no such module. Also tried installing using these instructions, but when I run the import, it hangs for a second or two and then says Failed to initialize libdc1394.
I then tried to install ffmpeg with pyffmpeg, but the most recent version of pyffmpeg I could find was released 3 years ago and built for Python2.6 on Ubuntu 10.10, while I am using 2.7 on Ubuntu 12.04.
Does anyone have experience installing either of these, or would recommend something else for this purpose?
If you are trying to install ffmpeg, you can do this more easily if you have homebrew and then use brew to install it. It's a lot more complicated otherwise.
If you just want to be able to complete this task, and it doesn't have to be the tool you're listing, you could try ffmpeg-python. After you have it installed, you can use the get_video_thumbnail example to get a single image. You could also probably tweak the read_frame_as_jpeg example to get a single image from a frame if you want.

Categories

Resources