tags:

views:

101

answers:

5
A: 

I am not an expert in Python, but one way to debug this is to launch the python prompt, and do import myModule then, some simple command that uses that module's constructs. If this works then your module installation is not the issue. If not your module wasnt installed.

omermuhammed
ok, I will try that and let you know how it goes.
ssdesign
A: 

You should see more than just the directory creation /usr/lib/python2.4/site-packages.

Arafangion
what exactly should I expect to see?
ssdesign
You should see a subdirectory there corresponding to the package in question, and you should see files in there corresponding to the implementation of that package.Additionally, if you're referring explicitly to the /usr/lib/python2.4 directory, you should refer explicitly to that version of python if you call it, rather than assuming that the default version is 2.4.
Arafangion
Sorry for the confusion, I do see my module directory and its files.And I also tried usr/bin/pythong as well as usr/bin/python2.4 .... both cases the module was not able to import
ssdesign
A: 

Did you tell python to look under /usr/lib/python2.4/site-packages/MyModule/ for your module(s)? (You need to put a *.pth file in /usr/lib/python2.4/site-packages/ for that, or maybe you should not put them into an extra directory.)

Try the following in a python shell:

>>> import sys
>>> sys.path

What does that print? Does it include '/usr/lib/python2.4/site-packages/MyModule'?

JanC
IF you look at the PHP exec() commend in my question, I gave Python the path of the module. Is that correct? because the sace exec() command works offline.
ssdesign
See the question I added above... :)
JanC
+1  A: 

You can check that the Python interpreter that you are calling sees your module by doing:

/usr/bin/python -c "import MyModule"

This command should simply import MyModule/__init__.py and not complain about MyModule not being found.

Since there are many modules in your code, you actually want to create a package, not a module.

To do so, you can simply add an empty __init__.py file in MyModule/ and all its subpackages, so as to indicate that you have a package (i.e. is a folder that contains many modules).

If your ttLib is in MyModule/myModule/ttLib/, you can do the same and add an empty __init__.py file in MyModule/ and MyModule/myModule/, so as to declare that MyModule and MyModule/myModule are packages; you can then simply do:

from MyModule.myModule.ttLib import …

Hope this helps! The full documentation for packages can be found on the official site.

EOL
Hi,the main file I am executing in script.py. Which resides in MyModule/myModule. THis script calls for another module which is inside MyModule/myModule/ttLib. The ttLib folder has a file called ____init____.py, this file contains a class called TTFont. This is the class that my script.py is trying to call by this line of code: "from myModule.ttLib import TTFont"
ssdesign
@ssdesign: I see. You do need to put a (possibly empty) `__init__.py` file in all three directories, including MyModule/ and MyModule/myModule/ (this makes these directories Python packages). Then, `from from MyModule.myModule.ttLib import TTFont` should work; it does on my machine (note the "double" `MyModule.myModule` prefix)…
EOL
@ssdesign: PS: You can check that your package is installed by doing `/usr/bin/python -c "import MyModule"`.
EOL
A: 

I reinstalled the module and everything works fine. It seems the module was not installed correctly.

ssdesign