Using Python 3.7 with libmapper

35 views
Skip to first unread message

Filipe Calegario

unread,
Jun 16, 2020, 7:56:26 PM6/16/20
to dot_m...@googlegroups.com
Hello people,

The workshop today was really nice!

I just got inspired to start a project with Python 3 and libmapper. However, I got some errors.

What I did:

I've used the flag:

./autogen.sh PYTHON=python3

make 

make install

cd swig

python3 test.py


and got the following error:

Traceback (most recent call last):

  File "test.py", line 4, in <module>

    import sys, mapper

  File "/Users/fcac/git/libmapper/swig/mapper.py", line 15, in <module>

    import _mapper

ImportError: dlopen(/Users/fcac/git/libmapper/swig/_mapper.so, 2): Symbol not found: _PyClass_Type

  Referenced from: /Users/fcac/git/libmapper/swig/_mapper.so

  Expected in: flat namespace

 in /Users/fcac/git/libmapper/swig/_mapper.so 

However, if I run it with Python 2.7, with 
python test.py it runs perfectly.

Am I missing something? Is that a common error? Quick fix?

Thank you!

Cheers!
Filipe Calegario

Stephen Sinclair

unread,
Jun 17, 2020, 5:49:48 AM6/17/20
to dot_m...@googlegroups.com
I'm unable to try on mac right now, but I can confirm that I'm able to
compile and run for python3.6 and python3.8 on Linux.
Not sure what's going on, but in principle it should work.

regards,
Steve
> --
> You received this message because you are subscribed to the Google Groups "dot_mapper" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dot_mapper+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dot_mapper/CA%2BudRQLgd0mbaHkN1VFFZUJ%3DZ24CVEnfe-YoQabF2fVVb1%3Dzow%40mail.gmail.com.

Max Graf

unread,
Jul 4, 2020, 8:47:19 AM7/4/20
to dot_mapper
+1 on this, especially as Python 2 support will be dropped next January. I tried the same procedure with Python 3.8.3 and got the same error message.

Regards,
Max

Joseph Malloch

unread,
Jul 9, 2020, 8:22:02 AM7/9/20
to dot_m...@googlegroups.com
Hi Filipe – if you ran autogen.sh without the PYTHON=python3 argument and built libmapper at some earlier point, the copywhich script may be copying an old python2 library instead. Try running:

make clean

and then repeat your previous steps.

Let us know if this works for you!
Joe

Stephen Sinclair

unread,
Jul 9, 2020, 3:36:44 PM7/9/20
to dot_m...@googlegroups.com
Oh wow I completely forgot about that script, good thinking Joe.

I just tried compiling for python2 and then python3 and it indeed gives an error, but a different one (on linux):

$ LD_LIBRARY_PATH=../src/.libs/ python3 test.py

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    import sys, mapper
  File "/home/sinclairs/projects/maint/libmapper/swig/mapper.py", line 15, in <module>
    import _mapper
ImportError: /home/sinclairs/projects/maint/libmapper/swig/_mapper.so: undefined symbol: _Py_ZeroStruct

It also absolutely chooses the wrong one:

$ ls build/
lib.linux-x86_64-2.7  lib.linux-x86_64-3.6  temp.linux-x86_64-2.7  temp.linux-x86_64-3.6

$ ./copywhich.sh python3 _mapper
build/lib.linux-x86_64-2.7/_mapper.so

I suppose the "copywhich.sh" script should be replaced, but in the meantime I provided a fix on master.

$ sh ./copywhich.sh python2 _mapper
build/lib.linux-x86_64-2.7/_mapper.so

$ sh ./copywhich.sh python3 _mapper
build/lib.linux-x86_64-3.6/_mapper.cpython-36m-x86_64-linux-gnu.so

Steve





Reply all
Reply to author
Forward
0 new messages