- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a python script where I want to import functions from numpy to use in fusion360.
I have a Mac with Python 2.7 which has the numpy module installed in /usr/local/lib/python2.7/site-packages. And from my Mac console python command line, I can import numpy successfully,
$ python
Python 2.7.10 (default, Sep 14 2015, 02:26:06)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = np.array([1, 2, 3])
>>> print type(a)
<type 'numpy.ndarray'>
>>>
I've read over this previous forum and it helped me to get going, but now I'm getting an import failure when I try to import numpy.
Here's my test script I am loading into Fusion360:
import adsk.core, adsk.fusion, traceback
## 1) did not work
#import sys
#sys.path.append("/usr/local/lib/python2.7/site-packages")
#import numpy as np
## 2) did not work
#import imp
#f, filename, desc = imp.find_module('numpy', ['/usr/local/lib/python2.7/site-packages'])
#np = imp.load_module('numpy', f, filename, desc)
## 3) almost works, but python crashes importing numpy
import sys
sys.path[0:0] = '/usr/local/lib/python2.7/site-packages'
import numpy as np
In Fusion360, I have clicked "Scripts and Add-ins" and selected my script and clicked "Edit". So now I am able to run and debug in the Spyder Python GUI.
When I run this test script in the Fusion360 Spyder GUI, I get this error message:
Welcome to Autodesk Fusion360 console!
Sample script:
import adsk.core
app = adsk.core.Application.get()
help(app)
>>> Traceback (most recent call last):
File "/Users/ali/Library/Application Support/Autodesk/Autodesk Fusion 360/API/Scripts/test_numpy_load/test_numpy_load.py", line 16, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
>>> Any pointers would be helpful and appreciated!
Thanks,
Sean
Solved! Go to Solution.