Difference between revisions of "User:StasFomin/AviSynth/Bugs/Pyscripter/No import from same directory"
From Wiki4Intranet
< User:StasFomin | AviSynth | Bugs | Pyscripter
Line 1: | Line 1: | ||
+ | Issue: When Run/debug from PyScripter, it is impossible to import modules from same directory. | ||
+ | |||
+ | Consider two almost empty file python modules <tt>a.py</tt> and <tt>b.py</tt> in the same directory, | ||
+ | <tt>a.py</tt> imports <tt>b.py</tt>. | ||
+ | |||
+ | * <tt>a.py</tt> successfully run in console, or from IDE, like <tt>Komodo IDE</tt>. | ||
+ | |||
[[File:Pyscripter. No import from same directory, 01.png]] | [[File:Pyscripter. No import from same directory, 01.png]] | ||
+ | |||
+ | * In <tt>pyscripter</tt>, if working directory is not equal to directory of <tt>a.py</tt> we have «ImportError: No module named b» | ||
[[File:Pyscripter. No import from same directory, 02.png]] | [[File:Pyscripter. No import from same directory, 02.png]] | ||
− | + | I use «engine type=remote» and RPyc because of http://code.google.com/p/pyscripter/issues/detail?id=256, but I see same problem with internal debug engine. | |
+ | |||
+ | Now I use ugly workaround: | ||
+ | |||
+ | <code-python> | ||
+ | import inspect, os | ||
+ | curpath = os.path.dirname(inspect.getfile(inspect.currentframe())) | ||
+ | sys.path.append(curpath) | ||
+ | </code-python> | ||
+ | |||
+ | but hope, that the issue can be fixed without it. | ||
+ | |||
+ | Any idea, what is wrong with me or PyScripter? | ||
+ | |||
+ | Thanks all in advance, | ||
+ | Sincerely, Stas Fomin |
Latest revision as of 19:13, 14 February 2012
Issue: When Run/debug from PyScripter, it is impossible to import modules from same directory.
Consider two almost empty file python modules a.py and b.py in the same directory, a.py imports b.py.
- a.py successfully run in console, or from IDE, like Komodo IDE.
- In pyscripter, if working directory is not equal to directory of a.py we have «ImportError: No module named b»
I use «engine type=remote» and RPyc because of http://code.google.com/p/pyscripter/issues/detail?id=256, but I see same problem with internal debug engine.
Now I use ugly workaround:
import inspect, os curpath = os.path.dirname(inspect.getfile(inspect.currentframe())) sys.path.append(curpath)
but hope, that the issue can be fixed without it.
Any idea, what is wrong with me or PyScripter?
Thanks all in advance, Sincerely, Stas Fomin