Python module import

Hello ,

I’m having trouble to import some python module in TD, No problem to import from the python shell. I have noticed that with module with an init.py in the folder. I don’t know if that is the reason ??? but look like the structure is different with a .egg folder with 2 folder inside (EGG-INFO and the module folder).
I have tried to set the path to the .egg folder and the sub folder with no success.

Any idea ?

Thanks,

Xavier

which module are you trying to import?

Have you reviewed the steps in derivative.ca/wiki088/index. … ng_Modules

Hello Rob,

It is the Python Twitter tools :
mike.verdone.ca/twitter/

Yes, I reviewed all steps mentioned there.
The package is available in the Python Shell.

You need the setuptools or its python 3 counterpart : distribute. to install the package.
If I got it, it is to manage dependencies during the install process.
It create a folder with a .egg extension
C:\Python32\Lib\site-packages\twitter-1.9.2-py3.2.egg
with 2 folders inside : EGG-INFO and Twitter.
I think my problem is to set the right path in TD
I tried with the parent foder.egg and the sub folder with no success. (with both TD 32 and 64bit).

Thanks

xavier

Hi Xavier.
Have you tried the solution for the other tweepy module in:
viewtopic.php?f=4&t=4773&p=17259#p17259

ie:
sys.path.append(“C:/Python32/Lib/site-packages”)
sys.path.append(“C:/Python32/Lib/site-packages/twitter-1.10.0-py3.2.egg”)

This works for me, but in this case you will need the upcoming build of TouchDesigner which has openssl compiled in.

PS to install it originally, I simply unzipped the twitter archive, cd’d to the folder and
C:/Python32/python.exe setup.py install

Hello Rob, Pixelux

Some Eggs archives do not have a setup.py for installing them. So here is a step-by-step method for installing those python modules.

Requirement:

  1. Download and install Python32 for your operating system:
    [url]http://www.python.org/download/releases/3.2/[/url]

Default installation path on windows: C:\Python32\

  1. Configure the setup tools:

-Download the distribute-setup script:
[url]http://python-distribute.org/distribute_setup.py[/url]

-Open a prompt command into the folder containing the distribute script:
-SHIFT-Right Click inside the folder (on windows)
-Open Windows Console

-Run the distribute-setup script:

 C:\Python32\python.exe distribute-setup.py

→ Setup tools are downloaded and then installed in your default python installation path.

  1. Install the needed python module

-Go to the Default python installation folder then inside the Scripts folder:
C:\Python32\Scripts

You should see the easy_install application.
If not something got wrong in the previous steps.

-Open a console windows into the Scripts folder
-Shift-Right Click Open Console

-Download the needed module:

easy_install name_of_the_module

Example:

easy_install twitter
  1. Configure Touch Designer to work with the module

In Touch Designer, create a python text DAT with the following code and run it:

import sys mypath = "C:/Python32/Lib/site-packages" if mypath not in sys.path: sys.path.append(mypath) mypath = "C:/Python32/Lib/site-packages/name_of_module.egg" if mypath not in sys.path: sys.path.append(mypath)

  1. That should be all.

Thanks for your detailed explanation.
It might have save me some time searching answers on the web…

Waiting for the next release to check if it works.

xavier

The posted build now has ssl included, enjoy!

Yes, Thanks Malcolm and all contributors to this topic.

It works like a charm :smiley:

Xavier