Saturday 15 May 2010

Python calling Method in Windows cmd -



Python calling Method in Windows cmd -

i have next unusual behavior:

i phone call python-file (lets name start.py), calls file:

import os time import sleep os.chdir("c:\path") execfile('yyy.py')

in pythons interpreter (python shell) uses execfile('start.py') , works perfekt - other file started , works fine

if run >_path_to_python/python.exe start.py in cmd, python started, start.py executed, os.chdir("c:\path") works, executed file yyy.py can't find modules:

from myclass import zzz importerror no mudule named myclass

i have empty __init__.py in folder, didn't work. i'am inthe right folder(if list files in yyy.py, lists modules...)

i realy don't understand why it's not working, because in sentiment after calling start.py there shouldn't difference between called cmd or manually anymore

okay manged solve problem (thanks @eryksun helping understand problem):

i added sys.path.append("c:\...\classes") python-code (before calling class) , works perfect. appends path class sys.path, interpreter looks libraries.

additionally gui crashed, after started, added -i parameter

>_path_to_python/python.exe -i start_prog.py

and python started in interactive mode , working.

windows python-2.7 cmd

No comments:

Post a Comment