Another "Import Error: No module named..." problem

If I run a Python script in Python it works PERFECTLY; however, adding this identical script inside the scripting window of Blender produces a constant error - Import Error: No module named ‘Phidgets’. I have spent over a week on this issue with no success. I have searched here and have found lots of identical questions (“Import Error: No module named ‘*”) but workable solutions are missing. I am using Python 3.3 and Blender 2.68. Please, experienced Blender/Python users, help.

Background: I am attempting to use a Phidgets Pressure Sensor to control the scale/size of an object. The Python code for the sensor works great and provides an output every time a pressure change occurs. I want to capture this pressure change and use it to change the object’s scale within Blender yet the 'Import Error: No module named ‘Phidgets’ is preventing this from working. How do I go about correcting this?
Sincerely,
Daryl G

Blender comes with its own python build-in, if you wanna use 3rd party libs or modules, make sure blender finds them

It usually means to placce those files into the appropriate folders in your blender directory

CoDEmanX,
Could you further define what you mean by placing those files into the “appropriate folders” in my blender directory? What is an appropriate folder? Should not the commands ‘from’ and ‘import’ find the named modules in the Blender console just as it does within the Python module? Again, it works perfectly in the Python module but fails in Blender… there is a plethora of other threads regarding the same type of problem but no valid answers. Both are 64-bit loads.
Thanks,
Daryl G

Sounds like a pathing issue to me.

Atom,
Thanks for the reply and link. I followed the directions of the link and when I amend my scripting to the same type (with the proper location of the files, DIRECTLY from my computer), Blender comes back with the same identical error. I will probably move on to another program because it looks as if Blender cannot properly synchronize with Phidgets… which is a requirement for my project.
Thanks,
Daryl G

You simply need to put your library in a path that is loaded by Blender. An easy way to find this out is to run this script in Blender.


import sys
print(sys.path)

That will show all the paths that Blender is searching for modules in.

That’s cool and super useful. I was wondering where you add something more to the path or at least thought that a good follow up question to provide that information here. I guess I am looking for the obvious startup scripts (Revealed in the path result scripts\startup) as opposed to doing this sys.path.append(module_dir) . I think you are suppose to be able to set an Environment variable

import os
os.environ[‘PYTHONPATH’]
‘/home/my_user/code’

But I am uncertain Blender respects that.
Okay well I guess you are suppose to put the append() command in a startup script. If there’s another way let us know, thanks.