When I run sudo pip install jinja2
I see: Requirement already satisfied: Jinja2 in /Users/rose/Library/Python/2.7/lib/python/site-packages/Jinja2-2.7.2-py2.7.egg
.
Yet running import jinja2
in a new python 2.7 shell gives: ImportError: No module named jinja2
Note that Jinja2 is installed in your home directory, and that Python's site-packages directory is located a /Library/Python/2.7/site-packages
. It's likely that either /Users/rose/Library/Python/2.7/lib/python/site-packages/
is not contained in your Python path, or Python does not have access to this directory. This may be the result of installing Jinja2 with pip install jinja2
instead of sudo pip install jinja2
.
You can check if /Users/rose/Library/Python/2.7/lib/python/site-packages/
by opening your Python shell:
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/dist-packages']
If not, the easiest solution may simply be to reinstall Jinja2 as admin:
pip uninstall jinja2
sudo pip install jinja2
Easiest solution by Mark Edge didn't worked for me, as pip installed jinja2 to place-not-in-path anyway.
Here is my development of solution:
pip install jinja2
again. You are going to get something like Requirement already satisfied: jinja2 in /usr/local/lib/python2.7/site-packages , and that's the path you need.I added to it:
export PATH="/usr/local/lib/python2.7/site-packages:$PATH"
PYTHONPATH="$HOME/Scripts/:$PATH"
If you already have PYTHONPATH line like above, add just the export one.
Restart your shell/Terminal windows for them to pick the new path.
Doing that fixed my problem "No module named jinja2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With