Forums

How to add files to a python package?

Hi all,

I am trying to add a couple of new jinja templates to an Ipython directory.

  • Where are the python packages located?
  • Can I add files to the existing python packages? If so, how?
  • Will the files I add be deleted at any point?

David Rojas
Website: https://hdrojas.pythonanywhere.com/

Hi David -- I'm not sure I understand your question. What will you be using the templates for? Is this IPython Notebook, or something of your own using IPython?

Hi Giles,

The templates are used to convert a notebook into different formats (html, latex, pdf, etc.) via nbconvert. I have created my own templates and in order to use them I need to place them in the following folder:

site-packages\IPython\nbconvert\templates

Thanks for that. One thing I should make clear -- we don't support IPython Notebook servers right now. You might be able to get it running temporarily, but there's no guarantee that it will work or continue to work.

But if this is some kind of IPython Notebook batch processing or something else that doesn't rely on having a server, I think the best thing to do would be to install the package locally in your home directory using

pip install --user packagename

...and then to put the templates insite your ~/.local/lib/python2.7/site-packages/IPython/nbconvert/templates directory.

I tried to pip install IPython but it says it is already installed:

20:14 ~ $ pip install --user IPython
Requirement already satisfied (use --upgrade to upgrade): IPython in /usr/local/lib/python2.7/dist-packages

I tried to manually copy the files but it says I do not have permission:

20:43 ~ $ cp /var/www/static/data/html_full2.tpl /usr/local/lib/python2.7/dist-packages/IPython/nbconvert/templates
cp: cannot create regular file ‘/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/templates/html_full2.tpl’: Permission denied

This looks like something that you should do inside a virtualenv. Especially if you want to upgrade to the very latest release of IPython.