import fails in non-interactive interpreter

Jean-Michel Pichavant jeanmichel at sequans.com
Thu Jan 26 08:49:21 EST 2012


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 at 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



More information about the Python-list mailing list