Help using Scipy for Python

So I finally figured out how to install scipy from lfd.uci.edu/~gohlke/pythonlibs/#pil

But now when I try to import scipy.spatial.Voronoi, I get this error:

RuntimeError: module compiled against API version 9 but this version of numpy is 7 Traceback (most recent call last): File "/project1/text1", line 1, in <module> File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) File "C:/Python33/Lib/site-packages\scipy\spatial\__init__.py", line 89, in <module> from .kdtree import * File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) File "C:/Python33/Lib/site-packages\scipy\spatial\kdtree.py", line 8, in <module> import scipy.sparse File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) File "C:/Python33/Lib/site-packages\scipy\sparse\__init__.py", line 206, in <module> from .csr import * File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) File "C:/Python33/Lib/site-packages\scipy\sparse\csr.py", line 13, in <module> from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \ File "C:/Program Files/Derivative/TouchDesigner088/bin/TouchInit.py", line 147, in tdcustomimport r = previousimport(*args, **kw) ImportError: numpy.core.multiarray failed to import

Can anybody point me to a version of scipy that will work?

Seems the issue is the distributed version of numpy that comes with TouchDesigner is incompatible with later versions of scipy.

You could install your own version of numpy into your standalone version of python.
You then need a way of getting TouchDesigner to ignore the built-in numpy:

import sys
sys.path.remove('C:\\Program Files\\Derivative\\TouchDesigner088\\bin\\lib\\site-packages')

I’ve now included this in:
derivative.ca/wiki088/index. … in_modules

Even with this, still can’t get
import scipy.spatial.Voronoi to work on any system (TouchDesigner or standalone python)
with my versions of scipy.

However I can get:

import scipy.spatial.qhull
C = qhull.Voronoi

to work.

Hope that helps.

Thank you Rob,

With your code to ignore the built-in numpy, I get this error:

Traceback (most recent call last): File "/project1/text1", line 2, in <module> ValueError: list.remove(x): x not in list

I checked to make sure the path is correct. Any idea what would cause this?

You’ll have to examine the list for the exact path unfortunately, which is dependent on installation location and 32 vs 64 bit and forward vs backslashes.

app.installFolder

should give you it the location of the parent folder at least.

Cheers
Rob.

Hey,
sorry to dig this up but I’m stuck here. Fairly new to TD, but I read through this thread and the wiki and got up until here…
Got a Script Dat that does:

import sys

tdPath = 'C:\\Program Files\\Derivative\\TouchDesigner088\\bin\\lib\\site-packages'
mypath = "C:/Python33/Lib/site-packages"
	
if tdPath in sys.path:
	sys.path.remove(tdPath)
	
if mypath not in sys.path:
	sys.path.append(mypath)

and another one that does:

import numpy print(numpy.__version__)

Sadly the Output of the second script in the Textport is still 1.7.0, eventhough it should be 1.9

any hints on where I might be going wrong? Is there a better way or place to call the path functions?

EDIT: reading through print(sys.path) helped to figure out the problem, removed the right path - works - yay!

It would be great if TD had support for python 3.4 or 3.5, with modules installed with Pip working out of the box. I tried very hard to make Scipy work with TD but i haven’t succeeded. It seems the reason is because there is no version of scipy compatible with 3.3, at least none is distributed.

Agreed.
We definitely have Python3.5 in the works, but no release date announced as of yet.
Thanks for your patience.
Rob.

It works with these two builds (not listed on the main page of Christoph Gohlke’s website):

Numpy cp33 64bits: lfd.uci.edu/~gohlke/pythonli … _amd64.whl
Scipy cp33 64bits: lfd.uci.edu/~gohlke/pythonli … _amd64.whl

Tip: use this link to get the list of all the builds for Python 3.3: lfd.uci.edu/~gohlke/pythonlibs/?q=cp33

Great tip. Weve updated the wiki with it