SpotlightKid / python-rtmidi

Python bindings for the cross-platform MIDI I/O library RtMidi
https://spotlightkid.github.io/python-rtmidi/
Other
356 stars 65 forks source link

Problems importing rtmidi (_rtmidi.so: undefined symbol) on Ubuntu with Anaconda #27

Closed memo closed 6 years ago

memo commented 6 years ago

Hi, firstly thanks for this wrapper!

I believe I have all of the dependencies installed, and I can pip install python-rtmidi, however when I import rtmidi I get the error below. Is this an incompatibility with Anaconda? Or am I missing something?

memo@MSA-BOX1-UBUNTU:~$ sudo apt-get install -yq build-essential libasound-dev libjack-dev
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version (12.1ubuntu2).
libasound2-dev is already the newest version (1.1.0-0ubuntu1).
libjack-dev is already the newest version (1:0.124.1+20140122git5013bed0-3build2).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

memo@MSA-BOX1-UBUNTU:~$ pip install -U mido python-rtmidi
Requirement already up-to-date: mido in ./anaconda2/lib/python2.7/site-packages
Requirement already up-to-date: python-rtmidi in ./anaconda2/lib/python2.7/site-packages

memo@MSA-BOX1-UBUNTU:~$ ipython
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import rtmidi
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-bb8660ccb28e> in <module>()
----> 1 import rtmidi

/home/memo/anaconda2/lib/python2.7/site-packages/rtmidi/__init__.py in <module>()
      2 from __future__ import absolute_import
      3 from .release import version as __version__  # noqa
----> 4 from ._rtmidi import *  # noqa
      5 from ._rtmidi import __doc__  # noqa
      6 del absolute_import

ImportError: /home/memo/anaconda2/lib/python2.7/site-packages/rtmidi/_rtmidi.so: undefined symbol: _ZTVNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE

System info:

Linux MSA-BOX1-UBUNTU 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

               platform : linux-64
          conda version : 4.3.18
       conda is private : False
      conda-env version : 4.3.18
    conda-build version : not installed
         python version : 2.7.13.final.0
       requests version : 2.14.2
       root environment : /home/memo/anaconda2  (writable)
    default environment : /home/memo/anaconda2
       envs directories : /home/memo/anaconda2/envs
                          /home/memo/.conda/envs
          package cache : /home/memo/anaconda2/pkgs
                          /home/memo/.conda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.18 requests/2.14.2 CPython/2.7.13 Linux/4.10.0-37-generic debian/stretch/sid glibc/2.23    
                UID:GID : 1000:1000
memo commented 6 years ago

Note, after running the openframeworks dependency installer scripts the error became this:

In [1]: import rtmidi
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-bb8660ccb28e> in <module>()
----> 1 import rtmidi

/home/memo/anaconda2/lib/python2.7/site-packages/rtmidi/__init__.py in <module>()
      2 from __future__ import absolute_import
      3 from .release import version as __version__  # noqa
----> 4 from ._rtmidi import *  # noqa
      5 from ._rtmidi import __doc__  # noqa
      6 del absolute_import

ImportError: /home/memo/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/lib/x86_64-linux-gnu/libjack.so.0)

which is fixed by conda install libgcc

I'm guessing the required packages were libjack-jackd2-0 libjack-jackd2-dev libasound2-dev (as opposed to libasound-dev libjack-dev ?)

SpotlightKid commented 6 years ago

Thanks for using python-rtmidi and for the report. I have to say this is not something, I've encountered before, but I did a quick search for the error message and came up with reports from several other projects using Cython for wrapping C++, which exhibited this error under Anaconda on Ubuntu. It seems to be caused by a certain mixture of the GCC version Anaconda's Python binary is compiled with, the Cython version and the GCC version of the system the Cython extension is compiled on.

Can you try to install python-rtmidi into its own virtualenv (i.e. created with virtualenv and the system Python not Anaconda) and report back whether the error occurs there too? Try Python 2 and Python 3, if you have both and make sure to update Anaconda and Cython to the latest versions.

With regards to the required *-dev packages: you're correct, it should be libasound2-dev instead of libasound-dev. libjack-jackd2-dev is listed correctly in the compilation requirements in the docs.

SpotlightKid commented 6 years ago

No more feedback, so closing this.