Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '*not*': 0.07; 'executed': 0.09; 'expected.': 0.09; 'file)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'structure,': 0.09; 'subject:module': 0.09; 'python': 0.11; 'vista': 0.14; 'windows': 0.15; '(empty': 0.16; '+--': 0.16; '__init__.py': 0.16; 'package;': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'skip:[ 40': 0.16; 'sys.path': 0.16; 'sys.path:': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'header:X-Complaints-To:1': 0.27; 'thus': 0.29; 'gives': 0.31; 'code': 0.31; 'accidentally': 0.31; 'file': 0.32; 'class': 0.32; 'skip:c 30': 0.32; 'subject:from': 0.34; 'window': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:* 10': 0.61; 'occur': 0.65; 'note:': 0.66; '*does': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Loading a module from a subdirectory Date: Tue, 11 Mar 2014 00:36:10 +0100 Organization: None References: <531E212D.2080909@it.uu.se> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd849c.dip0.t-ipconnect.de User-Agent: KNode/4.11.5 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394494582 news.xs4all.nl 2909 [2001:888:2000:d::a6]:38972 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68181 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?