Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68181 > unrolled thread

Re: Loading a module from a subdirectory

Started byPeter Otten <__peter__@web.de>
First post2014-03-11 00:36 +0100
Last post2014-03-11 00:36 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Loading a module from a subdirectory Peter Otten <__peter__@web.de> - 2014-03-11 00:36 +0100

#68181 — Re: Loading a module from a subdirectory

FromPeter Otten <__peter__@web.de>
Date2014-03-11 00:36 +0100
SubjectRe: Loading a module from a subdirectory
Message-ID<mailman.8026.1394494582.18130.python-list@python.org>
Virgil Stokes wrote:

> I have the following folder-file structure:
> 
>   C:/PythonCode/VideoPlayerSimulator/
>                                   +--  __init__.py   (empty file)
>                                   +--  GlbVars.py (contains the single
> class Glb)
> 
>   C:/PythonCode/VideoPlayerSimulator/RubberBanding/
>                                           +--  __init__.py
>                                           +--  ImportDemo.py
> 
>   where, ImportDemo.py contains the following code (a single line):
> 
> from VideoPlayerSimulator.GlbVars import Glb as G
> 
>   gives the following error when I execute it:
> 
> *ImportError: No module named VideoPlayerSimulator.GlbVars*
> 
>   Note:
>    1. My sys.path contains:
>       ['C:\\PythonCode\\VideoPlayerSimulator', ...]

VideoPlayerSimulator is a package; its *parent* directory has to be in 
sys.path:
     ['C:\\PythonCode', ...]

>    2. Python 2.7.5 on a Window 7 platform
>    3. The same ImportDemo.py file when executed on my Window Vista
>    platform
>       with the same folder-file structure, *DOES NOT* give an error and
> works
>       as expected.

This is *not* expected; perhaps C:\PythonCode is the current working 
directory and thus accidentally made it into sys.path as ''.
 
> Why does the error occur, and why does it not occur on the Windows Vista
> platform?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web