execute python script question

Sam samuel.progin at gmail.com
Mon Mar 10 17:29:36 EDT 2008


Hello,

I may misunderstand your problem, but it may be related to the
execution environment, especially the PYTHONPATH variable. Have a look
at the following log:

samuel at Bioman2:/$ pwd
/
samuel at Bioman2:/$ cat -n /tmp/test_import.py
     1  class A(object):
     2      def __init__(self):
     3          self.value = 1
     4      def show(self):
     5          print self.value
samuel at Bioman2:/$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from test_import import A
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named test_import
>>> exit()
samuel at Bioman2:/$ export PYTHONPATH=/tmp
samuel at Bioman2:/$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from test_import import A
>>> a=A()
>>> a.show()
1
>>>

++

Sam



More information about the Python-list mailing list