Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Overriding numpy

General discussion about anything TouchDesigner

Overriding numpy

Postby hmbemba » Mon Jul 01, 2019 10:35 am

Hey all,

I'm trying to import then pandas module which requires Numpy 1.12 or greater. I have Numpy 1.16 on laptops python path, but the version TD comes installed with is 1.11.

I was looking in the docs about overriding built in modules, but I'm still confused and couldn't get it to work - http://www.derivative.ca/wiki088/index. ... ng_Modules

Does anyone know of a way I can get TD to use the Numpy version on my system, rather than the numpy built into TD?

Thanks in advance!
hmbemba
 
Posts: 32
Joined: Mon Mar 27, 2017 6:48 pm

Re: Overriding numpy

Postby malcolm » Tue Jul 02, 2019 1:57 pm

You could try changing the sys.path so that the path to your numpy version is before the path to our numpy version. Does that work?
User avatar
malcolm
Staff
 
Posts: 4400
Joined: Tue Nov 13, 2007 1:11 am

Re: Overriding numpy

Postby hmbemba » Tue Jul 02, 2019 10:28 pm

Hey Malcom,

Could you be more specific as to how to do that? sys.path just yields a list of various python related folders, along with the site packages TD uses - it doesn't seem to go to the module level.
hmbemba
 
Posts: 32
Joined: Mon Mar 27, 2017 6:48 pm

Re: Overriding numpy

Postby nettoyeur » Wed Jul 03, 2019 5:19 am

see the chapter "Importing Modules" on the "introduction to Python Tutorial" page:
(more specifically the last paragraph titled "Overriding built in modules")
https://docs.derivative.ca/Introduction ... ng_Modules
Idzard Kwadijk | freelance TouchDesigner consultant | IdzArd.com
Checkout ChopChopChop.org - the TouchDesigner marketplace!
nettoyeur
 
Posts: 1151
Joined: Mon Oct 15, 2012 12:00 pm
Location: Amsterdam, The Netherlands

Re: Overriding numpy

Postby hmbemba » Wed Jul 10, 2019 5:24 pm

Hey nettoyeur,

That article was what I was referring to in my original post - I read it, but I'm still confused as to how to actually implement it.

I ran
Code: Select all
sys.path.remove('C:\\Program Files\\Derivative\\TouchDesigner099\\bin\\lib\\site-packages')


and got a value error saying
Code: Select all
ValueError: list.remove(x): x not in list


I printed out sys.path and sure enough the site-packages path wasn't in there - which confused me even more. If my the default TD sitepackages path isn't in sys.path, then how is TD importing the default modules like cv2 and numpy?
hmbemba
 
Posts: 32
Joined: Mon Mar 27, 2017 6:48 pm

Re: Overriding numpy

Postby hmbemba » Wed Jul 10, 2019 5:42 pm

I also tried
Code: Select all

import sys
mypath = "C:\\Users\\myusername\\Desktop\\Python37\\Lib\\site-packages\\numpy"
sys.path.insert(0, mypath)
import numpy
print(sys.path)
print(numpy.__version__)



Which did put numpy version 1.16 first in the sys.path, but when I printed numpy.__version it yielded version 1.11 - which is the TD default version
hmbemba
 
Posts: 32
Joined: Mon Mar 27, 2017 6:48 pm

Re: Overriding numpy

Postby rob » Fri Jul 19, 2019 11:53 am

Try without the numpy portion:


Code: Select all
import sys
sys.path.insert(0, "C:/Python35-x64/Lib/site-packages")
import numpy
print(numpy.__version__)


This works for me.

(I've updated the wiki!)

Cheers
User avatar
rob
Staff
 
Posts: 1671
Joined: Tue Nov 13, 2007 1:14 am


Return to General TouchDesigner Discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests