# Ctcsound import error

**URL:** <https://forum.csound.com/t/ctcsound-import-error/577>\
**Category:** General\
**Created:** [November 17, 2021, 10:53am UTC](https://forum.csound.com/t/ctcsound-import-error/577 "2021-11-17T10:53:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TetsuyaMiwa](https://forum.csound.com/user_avatar/forum.csound.com/tetsuyamiwa/32/181_2.png) [@TetsuyaMiwa](https://forum.csound.com/u/TetsuyaMiwa)\
**Post date:** [November 17, 2021, 10:53am UTC](https://forum.csound.com/t/ctcsound-import-error/577/1 "2021-11-17T10:53:03Z")

</div>

Hi,  
After updating ctcsound (I need to do it manually due to my Anaconda configuration), I found that importing ctcsound results in error.  
I tried ctcsound from csound-MacOS\_x86\_64-6.16.2.dmg and Csound source repository, but both cannot be imported. The error message is attached below.  
Is there any conflict with Python version?

MacBook Pro(Intel)  
MacOS 11.6.1(BigSur)  
Csound v6.16.2(installed from dmg)  
Python 3.8.11  
JupyterLab3.2.1

**Importing ctcsound from Csound 6.16.2 installer**

```csound
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/var/folders/08/p6f034s48xjbh80059bry1jr0000gn/T/ipykernel_5697/205267035.py in <module>
----> 1 import ctcsound

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/site-packages/ctcsound.py in <module>
   2703 sys.exit("Don't know your system! Exiting...")
   2704 
-> 2705 libcspt.NewCsoundPT.restype = ct.c_void_p
   2706 libcspt.NewCsoundPT.argtypes = [ct.c_void_p]
   2707 libcspt.DeleteCsoundPT.argtypes = [ct.c_void_p]

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/ctypes/ __init__.py in __getattr__ (self, name)
    384 if name.startswith('__') and name.endswith('__'):
    385 raise AttributeError(name)
--> 386 func = self. __getitem__ (name)
    387 setattr(self, name, func)
    388 return func

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/ctypes/ __init__.py in __getitem__ (self, name_or_ordinal)
    389 
    390 def __getitem__ (self, name_or_ordinal):
--> 391 func = self._FuncPtr((name_or_ordinal, self))
    392 if not isinstance(name_or_ordinal, int):
    393 func. __name__ = name_or_ordinal

AttributeError: dlsym(RTLD_DEFAULT, NewCsoundPT): symbol not found

```

**Importing ctcsound from Csound source repository**

```csound
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/var/folders/08/p6f034s48xjbh80059bry1jr0000gn/T/ipykernel_5758/205267035.py in <module>
----> 1 import ctcsound

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/site-packages/ctcsound.py in <module>
    421 libcsound.csoundCreateThread.restype = ct.c_void_p
    422 libcsound.csoundCreateThread.argtypes = [THREADFUNC, ct.py_object]
--> 423 libcsound.csoundCreateThread2.restype = ct.c_void_p
    424 libcsound.csoundCreateThread2.argtypes = [THREADFUNC, ct.c_uint, ct.py_object]
    425 libcsound.csoundGetCurrentThreadId.restype = ct.c_void_p

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/ctypes/ __init__.py in __getattr__ (self, name)
    384 if name.startswith('__') and name.endswith('__'):
    385 raise AttributeError(name)
--> 386 func = self. __getitem__ (name)
    387 setattr(self, name, func)
    388 return func

~/.pyenv/versions/anaconda3-2019.10/envs/dev38/lib/python3.8/ctypes/ __init__.py in __getitem__ (self, name_or_ordinal)
    389 
    390 def __getitem__ (self, name_or_ordinal):
--> 391 func = self._FuncPtr((name_or_ordinal, self))
    392 if not isinstance(name_or_ordinal, int):
    393 func. __name__ = name_or_ordinal

AttributeError: dlsym(0x7fcc4f787270, csoundCreateThread2): symbol not found

```

---

<div class="post-metadata">

**Author:** ![TetsuyaMiwa](https://forum.csound.com/user_avatar/forum.csound.com/tetsuyamiwa/32/181_2.png) [@TetsuyaMiwa](https://forum.csound.com/u/TetsuyaMiwa)\
**Post date:** [November 19, 2021, 1:09pm UTC](https://forum.csound.com/t/ctcsound-import-error/577/2 "2021-11-19T13:09:35Z")

</div>

I think I have solved the issue.  
Changing the line 2700 of ctcsound.py (provided by csound-MacOS\_x86\_64-6.16.2.dmg)  
from

```csound
elif sys.platform.startswith('darwin'):
    libcspt = ct.CDLL(ctypes.util.find_library('csnd6'))

```

to

```csound
elif sys.platform.startswith('darwin'):
    libcspt = ct.CDLL(ctypes.util.find_library('csnd6.6.0'))

```

seems to solve the issue.
