Difference between revisions of "User:StasFomin/AviSynth/Bugs/Pyscripter/No import from same directory"

From Wiki4Intranet
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Pyscripter. No import from same directory, 01.jpg]]
+
Issue: When Run/debug from PyScripter, it is impossible to import modules from same directory.
  
[[Pyscripter. No import from same directory, 02.jpg]]
+
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>.
  
[[Pyscripter. No import from same directory, 03.jpg]]
+
* <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]]
 +
 
 +
* 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]]
 +
 
 +
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.

Pyscripter. No import from same directory, 01.png

  • In pyscripter, if working directory is not equal to directory of a.py we have «ImportError: No module named b»

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:

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