# Python packages for mworks

**URL:** <https://mworks.discourse.group/t/python-packages-for-mworks/264>\
**Category:** Support\
**Created:** [April 20, 2019, 4:31pm UTC](https://mworks.discourse.group/t/python-packages-for-mworks/264 "2019-04-20T16:31:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 20, 2019, 4:31pm UTC](https://mworks.discourse.group/t/python-packages-for-mworks/264/1 "2019-04-20T16:31:46Z")

</div>

Hi Chris,  
I can’t seem to find the answer to this in the discussion/user manual, but apologies if it’s a redundant question.

I’m trying to call a python from mworks that includes some packages (pandas) that apparently are not included in the mworks-bundled python. I tried adding the path within the python file\*, but can’t seem to get it work\*\*. Any thoughts?

include code:\*  
import sys  
PYTHONPATH\_CONDA = ‘/Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/’  
sys.path.insert(0, PYTHONPATH\_CONDA)  
import pandas as pd

error\*\*:  
ImportError: dlopen(/Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/\_libs/tslib.so, 2): Symbol not found: \_PyCObject\_Type  
Referenced from: /Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/\_libs/tslib.so  
Expected in: flat namespace  
in /Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/\_libs/tslib.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/var/folders/xn/2zkbn8994kngz51j2kzrfh980000gn/T/MWorks/Experiment Cache/_Users\_rishi\_Dropbox_\_(MIT)\_JazLab\_rr\_mwk\_PONG\_from\_validation100.mwel/tmp/PONG\_utils.py”, line 5, in   
import pandas as pd  
File “/Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/ **init**.py”, line 35, in   
“the C extensions first.”.format(module))  
ImportError: C extension: dlopen(/Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/\_libs/tslib.so, 2): Symbol not found: \_PyCObject\_Type  
Referenced from: /Users/rishi/anaconda/envs/py27/lib/python2.7/site-packages/pandas/\_libs/tslib.so  
Expected in: flat namespace

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 20, 2019, 4:32pm UTC](https://mworks.discourse.group/t/python-packages-for-mworks/264/2 "2019-04-20T16:32:52Z")

</div>

Hi Chris,

Feel free to ignore this – it was due to mworks python not supporting c-types, and your solution [here](https://mworks.tenderapp.com/discussions/problems/374-new-mworks-python) worked.

Thanks,

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 20, 2019, 4:40pm UTC](https://mworks.discourse.group/t/python-packages-for-mworks/264/3 "2019-04-20T16:40:58Z")

</div>

Hi Rishi,

The problem is that MWorks bundles Python 3.7, but you’re trying to import a module that’s compiled against Python 2.7. Specifically, it’s failing to load because the module expects to find a symbol (\_PyCObject\_Type) that doesn’t exist in Python 3.7.

The solution is to use a version of pandas built against Python 3.7.

> it was due to mworks python not supporting c-types, and your solution here worked.

That’s good, although I don’t know _why_ it worked, since the initial problem wasn’t related to ctypes. Maybe pandas tries ctypes first, then falls back on the compiled module only if that fails?

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 8:53pm UTC](https://mworks.discourse.group/t/python-packages-for-mworks/264/4 "2022-07-19T20:53:56Z")

</div>


