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


Groups > comp.lang.python > #19491

Re: import fails in non-interactive interpreter

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <brian.brinegar@gmail.com>
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; 'python,': 0.01; 'instance,': 0.05; 'interpreter': 0.05; 'interpreter.': 0.07; 'skip:/ 40': 0.07; 'subject:fails': 0.07; 'python': 0.08; '>>>>': 0.09; 'absent': 0.09; 'dev': 0.09; 'structure.': 0.09; 'am,': 0.12; 'received:209.85.214.174': 0.13; 'cc:addr:python-list': 0.15; '"import': 0.16; 'executed.': 0.16; 'mode.': 0.16; 'skip:/ 50': 0.16; 'subject:import': 0.16; 'subject:non': 0.16; 'symbolic': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'help.': 0.18; 'jan': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '2.5,': 0.23; 'skip:[ 50': 0.23; 'cc:2**0': 0.25; 'creating': 0.25; 'mode': 0.25; "wasn't": 0.25; 'module': 0.26; 'import': 0.27; 'tried': 0.27; "i'm": 0.27; 'work.': 0.28; 'message-id:@mail.gmail.com': 0.28; 'assuming': 0.28; 'module.': 0.28; 'fixed': 0.29; 'print': 0.29; 'installed': 0.29; 'cc:addr:python.org': 0.29; 'skip:p 30': 0.29; 'environment': 0.30; 'imported': 0.30; "i've": 0.31; 'correct': 0.31; 'thu,': 0.32; 'value.': 0.32; 'received:209.85.214': 0.32; 'thanks': 0.32; 'there': 0.33; 'someone': 0.34; 'curious': 0.34; 'directory.': 0.34; 'identical': 0.34; 'changing': 0.34; 'brian': 0.35; 'help,': 0.35; 'moving': 0.35; 'issue': 0.35; 'file': 0.35; 'problem.': 0.36; 'post': 0.36; 'response,': 0.36; 'variables': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'hoping': 0.38; 'should': 0.38; 'but,': 0.38; 'fail': 0.38; 'i.e.': 0.38; 'difficult': 0.39; 'point': 0.39; 'why': 0.39; 'received:209': 0.39; 'greatly': 0.39; 'subject:: ': 0.39; 'did': 0.39; 'packages': 0.40; 'under': 0.40; 'more': 0.61; 'your': 0.61; 'link': 0.63; 'further': 0.64; 'here': 0.64; '26,': 0.67; 'anywhere.': 0.84; 'thoughts,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qoEZFbGtrs44VX9SxPG0+aYJVyg2EpEMPtlMhfuRqWY=; b=gd2vVXPrRJDuM24WwYZB9GABLnX/LfW7CezvtGluFff3wMue/bLiSNd8UVulWpg5ee o+Ekb1HccfinqPY11UjeaLeo0mTNyUftKPZqoiLKfDPJCeXMNxg/etNcs/pM/nf+x0o+ ShTGqvA183mPpuR48L5VjJXrjHOv6b1gsz5T8=
MIME-Version 1.0
In-Reply-To <4F2159E1.1010905@sequans.com>
References <9115def9-c2f6-4ac9-ae4b-8b1b8867ba7b@c21g2000yqi.googlegroups.com> <4F2131E1.6040105@sequans.com> <CAOWCkUPX-YNCCSbKx5RvJ9yc+mJ37ymBY3fxvQf3ZZKSXHiV4Q@mail.gmail.com> <4F2159E1.1010905@sequans.com>
Date Thu, 26 Jan 2012 09:37:41 -0500
Subject Re: import fails in non-interactive interpreter
From Brian Brinegar <brian.brinegar@gmail.com>
To Jean-Michel Pichavant <jeanmichel@sequans.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5128.1327588664.27778.python-list@python.org> (permalink)
Lines 123
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327588664 news.xs4all.nl 6877 [2001:888:2000:d::a6]:55247
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19491

Show key headers only | View raw


On Thu, Jan 26, 2012 at 8:49 AM, Jean-Michel Pichavant
<jeanmichel@sequans.com> wrote:
> Brian Brinegar wrote:
>>
>> JM,
>>
>> Thanks for the response, you're correct '' is pre-pended to the path
>> in interactive mode. I've tried adding . to my PYTHONPATH and it
>> doesn't solve the problem.
>>
>> When imported from interactive python the paste.deploy module is located
>> at:
>>
>>
>>>>>
>>>>> import paste.deploy
>>>>> paste.deploy.__path__
>>>>>
>>
>> ['/home/brian/webapps/test_dyn/lib/python2.7/paste/deploy']
>>
>> My path for both interactive and non-interactive contains:
>>
>> /home/brian/webapps/test_dyn/lib/python2.7
>>
>> From the interactive interpreter I can import paste if my working
>> directory is inside of the.
>>
>> /home/brian/webapps/test_dyn
>>
>> Moving to a working directory above "test_dyn" point causes the import
>> to fail in the interactive interpreter as well.
>>
>> I am able to import packages located the lib/python2.7/site-packages
>> directory of my virtualenv instance, but not the lib/python2.7
>> directory.
>>
>> Thanks again,
>> Brian
>>
>>
>>
>> On Thu, Jan 26, 2012 at 5:58 AM, Jean-Michel Pichavant
>> <jeanmichel@sequans.com> wrote:
>>
>>>
>>> Brian wrote:
>>>
>>>>
>>>> I've been banging my head against this for the past hour, and I'm
>>>> hoping someone here can set me straight.
>>>>
>>>>
>>>>
>>>
>>> [Snip]
>>>
>>>>
>>>> but, using the same same python, I'm able to import the module from
>>>> the interactive interpreter. The PATH and PYTHONPATH environment
>>>> variables are identical in both contexts.
>>>>
>>>>
>>>
>>> Are you sure ? with python 2.5, in interactive mode '' is happened to
>>> sys.path and is absent from it when a python file is executed.
>>>
>>> python -c "import sys; print '' in sys.path"
>>> True
>>> python test.py
>>> False
>>>
>>>
>>>>
>>>> Under what situations would a module be available to through the
>>>> interactive interpreter but not the non-interactive?
>>>>
>>>> I greatly appreciate any thoughts,
>>>> Brian
>>>>
>>>>
>>>
>>> As a more general notice, if you want to be able to import paste from
>>> everywhere, it must be properly installed as a python module.
>>>
>>> Cheers,
>>>
>>> JM
>>>
>
> Difficult to say without your PYTHONPATH value.
>
> Assuming your PYTHONPATH is
>
> /home/brian/webapps/test_dyn/lib/python2.7/site-packages
>
> 1/ paste is stable, copy the paste directory into
> /home/brian/webapps/test_dyn/lib/python2.7/site-packages
> 2/ paste is not stable, i.e. you're changing it from time to time, make a
> symbolic link to your dev paste directory within
> /home/brian/webapps/test_dyn/lib/python2.7/site-packages
>
> you should now be able to import paste from anywhere.
>
> JM
>
>
> PS : please don't top post

JM,

Thanks so much for all of your help. I added a symlink in
site-packages and it still did not work. Upon further investigation I
found that the there wasn't an __init__.py in the paste or
paste/deploy directories. Creating python2.7/paste/__init__.py and
python2.7/paste/deploy/__init__.py fixed the issue without a need for
the symlink.

I'm curious why the interactive interpreter is able to import this
without the proper package structure.

Thanks again for your help,
Brian

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

import fails in non-interactive interpreter Brian <brian.brinegar@gmail.com> - 2012-01-25 18:25 -0800
  Re: import fails in non-interactive interpreter Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-01-25 22:04 -0500
  Re: import fails in non-interactive interpreter Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-26 11:58 +0100
  Re: import fails in non-interactive interpreter Brian Brinegar <brian.brinegar@gmail.com> - 2012-01-26 07:47 -0500
  Re: import fails in non-interactive interpreter Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-26 14:49 +0100
  Re: import fails in non-interactive interpreter Brian Brinegar <brian.brinegar@gmail.com> - 2012-01-26 09:37 -0500

csiph-web