[IPython-dev] %install_ext question

Thomas Kluyver takowl at gmail.com
Tue Apr 9 12:56:41 EDT 2013


Ah, sorry, I had got confused. Python can *run* a zip file containing a
__main__.py file. It can't import a zip file.

So, for now, carry on using pip to install anything bigger than a single
module.

Thomas


On 9 April 2013 17:43, Greg Novak <greg.novak at gmail.com> wrote:

> Sorry for the delay in responding to this.
>
> If I just put the zip file in a directory on sys.path, I can't import it.
>  I tried it both where the zip file contained the leading directory (so
> grasp/grasp.py and grasp/__init__.py) and also where the zip file just
> contained grasp.py and __init__.py at the top level.
>
> But if I put the zip file itself on the path via sys.path +=
> ['blah/blah/grasp.zip'] then I can import grasp using either of the two zip
> file structures above.
>
> Greg
>
>
>
> On Wed, Apr 3, 2013 at 2:36 PM, Thomas Kluyver <takowl at gmail.com> wrote:
>
>> On 3 April 2013 13:12, Greg Novak <greg.novak at gmail.com> wrote:
>>
>>> It does indeed put the file into .ipython/extensions, but then to use it
>>> I need to put the zip file in sys.path explicitly.  Just having the zip
>>> file in the extensions directory isn't enough.  So if I also do:
>>>
>>> import sys
>>> sys.path += ["/Users/novak/.ipython/extensions/grasp.zip"]
>>>
>>
>> Is the zip file itself importable? i.e. if you put the directory
>> containing the zip file on your PYTHONPATH, can you do 'import grasp'? I
>> think it needs to be structured so that the top level of the zip file
>> contains an __init__.py file.
>>
>> But it's fine to install using pip instead - it's a deliberate feature
>> that an extension is simply any importable module with a
>> load_ipython_extension() function at the top level. Sympy, for example,
>> includes an IPython extension as part of its installation.
>>
>> Thomas
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130409/35ea3b74/attachment.html>


More information about the IPython-dev mailing list