New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jinja2 in Python 3 import error #408
Comments
What's |
there's no |
Then it looks like you have a partial install of jinja2 (i.e. missing everything). Try:
If that doesn't work, you might try uninstalling it first. |
I'm really at a loss here. Is it a requirement of python 2.7, or 3.4? Those are the two I have installed locally, but I believe Jupyterhub uses 3.4.
Want to verify that it was removed:
Looks like it's gone, so reinstall:
Now check if it was completely installed, looks like NO!:
|
And what's |
|
Something's really fishy. What do you get from When you uninstall jinja2, does that directory still exist? |
When I'd uninstalled jinja2, the directory was gone:
But it is back now after the reinstall:
|
It looks like there is something wrong with my Unfortunately, now there is an error under
I tried also installing ipython-notebook for python3 with apt-get, but that wasn't found in the class path for jupyterhub. It appears that my |
Try this:
|
|
Arg, that seems like setuptools and/or pip has really messed itself up. When it gets to that degree, I'm tempted to trash the entirety of |
@statueofmike If you installed pip or pip3 using apt-get it is possible that you may have an old version of pip or pip3. Before trashing the entirety of |
You could also use a virtualenv to see if the problem goes away there, instead of trashing your /usr/local/lib/ |
SOLVEDI tried reinstalling pip and pip3 altogether first. This didn't seem to help. Then I trashed my entire Here I realized the problem: for some reason, the file system permissions were restricting user Python sessions from loading these packages properly. $ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jinja2
>>> dir(jinja2)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
sudo chmod -R 775 /usr/local/lib/python3.4/dist-packages/
$ python3
>>> import jinja2
>>> dir(jinja2)
['BaseLoader', 'BytecodeCache', 'ChoiceLoader', 'DebugUndefined', 'DictLoader', 'Environment', 'FileSystemBytecodeCache', 'FileSystemLoader', 'FunctionLoader', 'Markup', 'MemcachedBytecodeCache', 'ModuleLoader', 'PackageLoader', 'PrefixLoader', 'StrictUndefined', 'Template', 'TemplateAssertionError', 'TemplateError', 'TemplateNotFound', 'TemplateSyntaxError', 'TemplatesNotFound', 'Undefined', 'UndefinedError', '__all__', '__builtins__', '__cached__', '__doc__', '__docformat__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_compat', '_stringdefs', 'bccache', 'clear_caches', 'compiler', 'contextfilter', 'contextfunction', 'defaults', 'environment', 'environmentfilter', 'environmentfunction', 'escape', 'evalcontextfilter', 'evalcontextfunction', 'exceptions', 'filters', 'is_undefined', 'lexer', 'loaders', 'make_logging_undefined', 'nodes', 'optimizer', 'parser', 'runtime', 'tests', 'utils', 'visitor'] Now I seem to have created a NEW problem. The Jupyterhub launcher also had too restrictive permissions. I'd installed with
Open QuestionWhy did I have this file permission issue? Should I have installed differently? |
That's quite strange. Do you see similar permission issues on any other packages? |
I'm seeing other strange errors now.
Jupyterhub throws the following error:
|
That means that the pkg_resources module, the underpinning of setuptools itself, is completely broken or missing. When you do import pkg_resources
print(pkg_resources.__file__) what do you see? |
I see this: >>> import pkg_resources
>>> print(pkg_resources.__file__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__file__'
>>> dir(pkg_resources)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> print(pkg_resources.__path__)
_NamespacePath(['/usr/local/lib/python3.4/dist-packages/pkg_resources']) |
And |
$ sudo ls -la /usr/local/lib/python3.4/dist-packages/pkg_resources
total 114
drwxr-Sr-- 5 root staff 1024 Feb 15 12:46 .
drwxrwsr-x 64 root staff 3072 Feb 15 12:46 ..
drwxr-Sr-- 3 root staff 1024 Feb 15 12:46 extern
-rw-r--r-- 1 root staff 108616 Feb 15 12:46 __init__.py
drwxr-Sr-- 2 root staff 1024 Feb 15 12:46 __pycache__
drwxr-Sr-- 4 root staff 1024 Feb 15 12:46 _vendor |
All users should have If this is the only issue, you can fix it by ensuring that all directories are world-readable:
That's: find all directories in dist-packages and give everyone execute (aka listing) permissions on those directories |
I ran the command to enable world-readable directories. pip3 has the same problem trying to install e.g. Is there a safe way to just remove all python altogether and reinstall it? Maybe I used |
You can remove all of the pip-installed packages easily enough, by removing
That will leave some broken entrypoints in It would be unwise to remove the system-installed packages without going through apt. |
is it supposed to be |
@statueofmike It's as written by @minrk. ☀️ |
Closing this issue as it's been inactive for several months. Please feel free to open a new issue at the jupyter/help repo or leave a comment requesting to reopen this issue. Thanks! 🌻 |
Improving pre-populating instructions
I installed Jupyterhub on Ubuntu 14.04, then run it as sudo. When logging in, the following error comes up:
I tried reinstalling Jupyterhub and jinja2.
When I run python3, I can do
import jinja2; dir(jinja2)
and it looks like something is wrong there:Here is my system information:
The text was updated successfully, but these errors were encountered: