On Ubuntu Precise PyEPL does not work when building from source or when installing from NeuroDebian. The following errors occur when importing the module installed from package, and when trying to install from source:
:~/Downloads/pyepl-1.0.29$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyepl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyepl/__init__.py", line 15, in <module>
import hardware
File "/usr/lib/python2.7/dist-packages/pyepl/hardware/__init__.py", line 25, in <module>
import sound
File "/usr/lib/python2.7/dist-packages/pyepl/hardware/sound/__init__.py", line 13, in <module>
from eplSound import eplSound as EPLSound
File "/usr/lib/python2.7/dist-packages/pyepl/hardware/sound/eplSound.py", line 26, in <module>
_eplSound = swig_import_helper()
File "/usr/lib/python2.7/dist-packages/pyepl/hardware/sound/eplSound.py", line 22, in swig_import_helper
_mod = imp.load_module('_eplSound', fp, pathname, description)
ImportError: /usr/lib/python2.7/dist-packages/pyepl/hardware/sound/_eplSound.so: undefined symbol: snd_pcm_hw_params_set_channels
>>>
:~/Downloads/pyepl-1.0.29$ python setup.py install
make: Entering directory `/mnt/grey/home/dream/mingus/Downloads/pyepl-1.0.29/code/hardware/sound'
g++ -pthread -fno-strict-aliasing -DNDEBUG -O2 -Wall -fPIC -I/usr/include/python2.7 -c eplSound.cpp -o eplSound.o
eplSound.cpp: In constructor ‘eplSound::eplSound(long int, long int, int, int)’:
eplSound.cpp:27:10: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:27:22: error: ‘exit’ was not declared in this scope
eplSound.cpp:187:12: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:187:24: error: ‘exit’ was not declared in this scope
eplSound.cpp:196:12: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:196:24: error: ‘exit’ was not declared in this scope
eplSound.cpp:210:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:210:19: error: ‘exit’ was not declared in this scope
eplSound.cpp:219:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:219:19: error: ‘exit’ was not declared in this scope
eplSound.cpp:231:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:231:19: error: ‘exit’ was not declared in this scope
eplSound.cpp:239:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:239:19: error: ‘exit’ was not declared in this scope
eplSound.cpp: In member function ‘int eplSound::startstream()’:
eplSound.cpp:315:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:315:19: error: ‘exit’ was not declared in this scope
eplSound.cpp:327:9: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:327:21: error: ‘exit’ was not declared in this scope
eplSound.cpp:337:9: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:337:21: error: ‘exit’ was not declared in this scope
eplSound.cpp: In member function ‘int eplSound::stopstream()’:
eplSound.cpp:358:7: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:358:19: error: ‘exit’ was not declared in this scope
eplSound.cpp:370:9: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:370:21: error: ‘exit’ was not declared in this scope
eplSound.cpp:380:9: error: ‘EXIT_FAILURE’ was not declared in this scope
eplSound.cpp:380:21: error: ‘exit’ was not declared in this scope
eplSound.cpp: In function ‘int inout(char*, int, void*)’:
eplSound.cpp:468:98: error: ‘memset’ was not declared in this scope
eplSound.cpp: In function ‘int playcall(char*, int, void*)’:
eplSound.cpp:490:98: error: ‘memset’ was not declared in this scope
make: *** [eplSound.o] Error 1
make: Leaving directory `/mnt/grey/home/dream/mingus/Downloads/pyepl-1.0.29/code/hardware/sound'
!!! Compilation Error !!!
Make failed for target hardware/sound
Exiting...Please fix the above error and try again...
These errors can be fixed by taking the following steps:
1) Add #include <alsa/asoundlib.h> to code/hardware/sound/eplSoundcpp
2) Add #include <limits.h> to code/hardware/sound/RtAudio.cpp
3) Change #include <string> to #include <string.h> in code/hardware/sound/fifo.h
4) Change #include <string> to #include <string.h> and add #include <stdlib.h> to code/hardware/eeg/pulse/parallel.h
5) Create a symlink from swig to swig2.0 on the system: sudo ln -s /usr/bin/swig2.0 /usr/bin/swig
These changes appear to be fixed in in trunk, so if you get the latest that also works:
git clone git://git.debian.org/git/pkg-exppsy/pyepl.git
cd pyepl
sudo python setup.py install
However, a new error that another user experienced in 2009 (https://sourceforge.net/projects/pyepl/forums/forum/548620/topic/3462970) resurfaces:
:~/Downloads/pyepl$ python
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyepl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pyepl/__init__.py", line 15, in <module>
import hardware
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/__init__.py", line 24, in <module>
import eeg
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/eeg/__init__.py", line 17, in <module>
from pulse import Parallel
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/eeg/pulse/__init__.py", line 15, in <module>
from parallel import Parallel
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/eeg/pulse/parallel.py", line 26, in <module>
_parallel = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/eeg/pulse/parallel.py", line 18, in swig_import_helper
import _parallel
ImportError: No module named _parallel
There is no actual fix listed in that thread. Part of the problem here is that in python 2.7 implicit relative imports are no longer supported, thus, PyEPL is broken. This is a bug in pyepl which can be temporarily fixed by modifying your PYTHONPATH:
export PYTHONPATH=/usr/lib/python2.7/dist-packages/pyepl/hardware/eeg/pulse:/usr/lib/python2.7/dist-packages/pyepl/hardware/sound/
Sadly, this causes another error to resurface:
>>> import pyepl
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pyepl/__init__.py", line 15, in <module>
import hardware
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/__init__.py", line 25, in <module>
import sound
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/sound/__init__.py", line 13, in <module>
from eplSound import eplSound as EPLSound
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/sound/eplSound.py", line 26, in <module>
_eplSound = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/pyepl/hardware/sound/eplSound.py", line 18, in swig_import_helper
import _eplSound
ImportError: /usr/lib/python2.7/site-packages/pyepl/hardware/sound/_eplSound.so: undefined symbol: snd_pcm_hw_params_set_channels
The symbol snd_pcm_hw_params_set_channels lives in alsa-util.so:
$ grep snd_pcm_hw_params_set_channels /usr/lib/pulse-1.1/modules/libalsa-util.so
Binary file /usr/lib/pulse-1.1/modules/libalsa-util.so matches
However, /usr/lib/python2.7/dist-packages/pyepl/hardware/sound/_eplSound.so is not linked against /usr/lib/pulse-1.1/modules/libalsa-util.so:
$ ldd /usr/lib/python2.7/dist-packages/pyepl/hardware/sound/_eplSound.so
linux-vdso.so.1 => (0x00007fff5031f000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f559a713000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f559a4fd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f559a13f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5599e45000)
/lib64/ld-linux-x86-64.so.2 (0x00007f559ac5a000)
This suggests that the _eplSound swig module is being compiled incorrectly in code/hardware/Makefile, on this line:
g++ -lpthread -lasound -shared eplSound_wrap.o eplSound.o RtAudio.o fifo.o -o _eplSound.so
We can modify this to link against the right library:
sudo ln -s /usr/lib/pulse-1.1/modules/libalsa-util.so /usr/lib/libalsa-util.so
g++ -lalsa-util -lpthread -lasound -shared eplSound_wrap.o eplSound.o RtAudio.o fifo.o -o _eplSound.so
While this code compiles, _eplSound.so is sadly not actually linked against libalsa-util so the problem perists. I will update if I come up with a fix.
The final bug ("undefined symbol: snd_pcm_hw_params_set_channels") can be fixed like so:
1) sudo ln -s /usr/lib/pulse-1.1/modules/libalsa-util.so /usr/lib/libalsa-util.so
2) Change the make command for _eplSound.so in code/hardware/sound/Makefile to:
g++ -Wl,--no-as-needed -lalsa-util -lpthread -lasound -shared eplSound_wrap.o eplSound.o
RtAudio.o fifo.o -o _eplSound.so
I've encountered the same problem on Ubuntu Quantal and Raring. This seems to be specific to Ubuntu (it works fine on Debian) and therefore should be raised with the Ubuntu people. To make sure this bug gets attended to quickly, please log in to Launchpad (or create an account) and indicate that this bug affects you, too):
https://bugs.launchpad.net/ubuntu/+source/pyepl/+bug/1171573