I followed the Pyramid tutorials and everything worked fine. Then I installed jinja2 for Pyramid and added the necessary lines of code to my development.ini
file. My templates were found at the specified location as expected. They were also rendered as I expected them to be. However, after doing a restart on my computer and then working with Alembic and SQLAlchemy, I went to view my site and now it's not finding the template directory. In specific, the error I am getting is:
jinja2.exceptions.TemplateNotFound
TemplateNotFound: my_project:templates/index.jinja2;
asset=/Users/John/project/projectenv/lib/python2.7/site-packages/my_project-0.0-py2.7.egg/my_project/templates/index.jinja2;
searchpath=['/Users/John/project/projectenv/lib/python2.7/site-packages/my_project-0.0-py2.7.egg/my_project/templates']
In my development.ini
file I have specified:
[app:main]
use = egg:my_project
jinja2.directories = my_project:templates
For some frame of reference, my file structure looks like this:
/project
/projectenv
/bin
/development.ini
/lib # where the "python2.7/site-packages/etc." is located
/my_project
/my_project # "main" project folder
/__init__.py
/models.py
/scripts
/static
/templates
/<the templates I would like to use>
/views.py
Two questions:
../python2.7/site-packages/my_project-0.0-py2.7.egg/my_project/templates
, I found "remnants" of my files from my "main" /my_project
directory. In particular, the templates
folder and it's contents were not present, but, views
, models
, __init__
, etc. were (although any recent updates to these files were not present). When I make updates to the "main" my_project files, Pyramid doesn't recognize those changes. I need to go into my "...2.7.egg" file, and make changes there for Pyramid to recognize them. Why might this be? Is my development.ini
file not configured properly? Or, is this something totally unrelated?
I'm baffled, and not sure what to do. Any thoughts, suggestions, and straight up answers are much appreciated.
Thanks for your help.
Sounds like you ran python setup.py install
at some point, which caused your project to get installed to the environment's site-packages directory. Removing the "my_project" directories/files from site-packages and running python setup.py develop
creates a symlink of your project to site-packages and your changes should work instantly. And when the module is properly available in site-packages, the template lookup should work too.