How does one add python libraries to 088? I am trying to add access to couchDBkit. Does anyone have a step-by-step walkthrough of the process?
Thanks.
How does one add python libraries to 088? I am trying to add access to couchDBkit. Does anyone have a step-by-step walkthrough of the process?
Thanks.
Well, I didnât personally investigate into it yet, but it seems there is an example project here:
viewtopic.php?f=22&t=3780
Thanks, I had looked at that one but didnât understand it at first.
I was able to get some other libraries loaded by changing permissions on the Derivative folder to allow me to write to it. You can then download your package, Shift+RMB on the folder setup.py lives in and choose âOpen Command Window Hereâ. Then use the following at the command prompt to install:
"C:\Program Files\Derivative\TouchDesigner088 64-Bit\bin\python.exe" setup.py install
This will install the package in the TouchDesigner\bin\Lib\site-packages folder so it can be found when you import. Hopefully thatâs helpful to people.
I still have problems with couchdbkit. Maybe because it is not really ready for Python3? I get this with just import couchdbkit and Run Script in a textDAT. Ideas anyone?
Traceback (most recent call last):
File "/project1/text1", line 1, in <module>
File "C:\Program Files\Derivative\TouchDesigner088 64-Bit\bin\lib\site-packages\couchdbkit-0.6.3-py3.2.egg\couchdbkit\__init__.py", line 8, in <module>
from .resource import RequestFailed, CouchdbResource
File "C:\Program Files\Derivative\TouchDesigner088 64-Bit\bin\lib\site-packages\couchdbkit-0.6.3-py3.2.egg\couchdbkit\resource.py", line 113
except ResourceError, e:
^
SyntaxError: invalid syntax
At first glance, looks like the module youâre trying to link with Python is failing under the new 3.x syntax.
From the website:
couchdbkit.org/download.html
It mentions âpython 3.x will be supported soonâ
That being said, modifying the TouchDesigner installation folder directly often causes problems in Windows installers trying to repair themselves etc.
A better approach, would be to:
This is done with regular list manipulation:
import sys
sys.path.append(mymodulepath)
You shouldnât keep appending to the list though.
So either:
or
if mymodulepath not in sys.path:
sys.path.append(mymodulepath)
import mymodule
or
try:
import mymodule
except ImportError:
sys.path.append(mymodulepath)
import mymodule
Let us know if you require more details.
Cheers,
Rob
Thanks for all of the info Rob,
I reinstalled TouchDesigner and Python to get all the default permissions back. I seem to be able to install some things correctly but I guess some of the modules just arenât ready for python 3 so they fail when installing.
It seems like TD is happy finding the modules Iâve installed without appending the locations but I havenât done extensive testing yet. The textport is at least not yelling at me when I import them.
Since couchDBkit and pyCurl wonât work is there and equivalent to the T-Script âsystemâ command so I can send curl to couchDB directly from my Python script without having to send it to another textDAT and then using another DATexecute to run the script as T-Script?
Look into the subprocess module, its how you run external processes in python.
Python import may be a bit tedious: 3 hours that I try to get pywin32 working with Touch Designer with no luck.
If anyone got success to make pywin32 working with TD or to correclty install it, itâll be kind to point me the right way of doing this.
Here what iâve gone into so far:
Installation of Python 3.2 - 64 bits at C:\Python32
Installation of the pywin32-217.win-amd64-py3.2.exe binary for python 3.2.
Command Prompt at C:\Python32\Scripts and
pywin32_postinstall.py -install
libpath = 'C:\\Python32\\lib\\site-packages'
if libpath not in sys.path:
sys.path.append(libpath)
import win32com.client
Which rises an Attribute Error. Anyway, it may be a pywin32 related issue rather than a TD issue.
Edit: though, and even if that doesnât solve the above error, one issue is that one needs to import each folder separately for modules to be imported
libpath = 'C:\\Python32\\lib\\site-packages'
lib1 = 'C:\\Python32\\lib\\site-packages\\win32\\test'
lib2 = 'C:\\Python32\\lib\\site-packages\\win32\\lib'
if libpath not in sys.path:
sys.path.append(libpath)
sys.path.append(lib1)
sys.path.append(lib2)
import win32com.client
Hi ab30.
One small thing Ive discovered, if you want to have the modules automatically visible to all TouchDesigner files, simply append their paths (separated by semicolons) to a system environment variable called PYTHONPATH.
In your case:
PYTHONPATH=
âC:/Python32/lib/site-packages;C:/Python32/lib/site-packages/win32/testâ;C:/Python32/lib/site-packages/win32/libâ
(Forward slashes work in my examples, though I havenât tested backslashes as youâre using).
Iâve listed all this info here for future reference:
derivative.ca/wiki088/index. ⌠ng_Modules
Good luck with your pywin32 issue. Let us know if youâve solved it.
Cheers,
Rob
Hi Rob,
Thanks for the tip about PYTHONPATH.
Iâve not continued to try to implement pywin32, as it seems their installer is a bit inconsistent.
I wanted to use this library mainly for coding into VBscript directly inside Touch Designer, but for the moment, Iâm going to wait for a more stable installation package, if it is updated one day.
Edit: That said, i installed the 32 bits version of pywin32 and it seems to work with python, but not with Touch Designer.
The following code works into the python console but rises a DLL import error with Touch Designer 32 bits:
Python Console:
import win32com.client
sc = win32com.client.Dispatch("ScriptControl")
sc.language = "vbscript"
sc.addcode("""msgBox ("Hello World!")""")
TD:
PYTHONPATH="C:/Python32/lib/site-packages;C:/Python32/lib/site-packages/win32/test';C:/Python32/lib/site-packages/win32/lib"
import win32com.client
sc = win32com.client.Dispatch("ScriptControl")
sc.language = "vbscript"
sc.addcode("""msgBox ("Hello World!")""")