notebook icon indicating copy to clipboard operation
notebook copied to clipboard

ImportError: cannot import name 'Environment'

Open Shiv751 opened this issue 7 years ago • 8 comments
trafficstars

  • python- 3.5.2
  • win 7 64bit
  • Jupyter Notebook installing issue
Traceback (most recent call last):
  File "c:\users\sem\appdata\local\programs\python\python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\sem\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\SEM\AppData\Local\Programs\Python\Python35\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
  File "c:\users\sem\appdata\local\programs\python\python35\lib\site-packages\notebook\notebookapp.py", line 38, in <module>
    from jinja2 import Environment, FileSystemLoader
ImportError: cannot import name 'Environment'

Shiv751 avatar Feb 12 '18 17:02 Shiv751

Do you have a file called jinja2.py? If so, Python is finding that instead of the real jinja2 package; you'll need to remove/rename it to make it work.

If it's not that, try uninstalling and reinstalling.

takluyver avatar Feb 13 '18 11:02 takluyver

It doesn't working @takluyver Getting same error

Traceback (most recent call last):
  File "c:\users\sem\appdata\local\programs\python\python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\sem\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\SEM\AppData\Local\Programs\Python\Python35\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
  File "c:\users\sem\appdata\local\programs\python\python35\lib\site-packages\notebook\notebookapp.py", line 38, in <module>
    from jinja2 import Environment, FileSystemLoader
ImportError: cannot import name 'Environment'

Shiv751 avatar Feb 18 '18 07:02 Shiv751

Open a Python shell, do import jinja2 and then print(jinja2) to see what file it's being loaded from. Make sure it's the real Jinja2 package.

takluyver avatar Feb 26 '18 17:02 takluyver

Hello, I have same issue on centos 7.

from jinja2 import Environment, PackageLoader, select_autoescape Traceback (most recent call last): File "", line 1, in ImportError: cannot import name Environment

print(jinja2) <module 'jinja2' from '/usr/lib64/python2.7/site-packages/jinja2'>

If I run python shell with sudo then I am able to import Environment. Looks like some issue with permissions to the packaged. Don't know how it is possible to import jinja2 without sudo and not be able to import Environment.

aprudnik avatar May 10 '18 10:05 aprudnik

For me, the error is:

from jinja2 import Environment, FileSystemLoader
ImportError: cannot import name 'Environment'

I solved it by downgrading jinja2 from 2.9.6 to 2.8.

Shuai-Xie avatar Nov 12 '19 10:11 Shuai-Xie

For me, the error is:

from jinja2 import Environment, FileSystemLoader
ImportError: cannot import name 'Environment'

I solved it by downgrading jinja2 from 2.9.6 to 2.8.

which command you have used to do this ?

Dhrumil-Zion avatar Jun 15 '20 07:06 Dhrumil-Zion

please help. File "C:\Users\dell\Anaconda3\envs\uner\lib\site-packages\notebook\notebookapp.py", line 45, in from jinja2 import Environment, FileSystemLoader ImportError: cannot import name 'Environment'

Fida1316 avatar Nov 08 '22 21:11 Fida1316

Do you have a file called jinja2.py? If so, Python is finding that instead of the real jinja2 package; you'll need to remove/rename it to make it work.

If it's not that, try uninstalling and reinstalling.

thanks,bro i've benn searched many ways to do ,but you solve it with one word

ruinabyss avatar Mar 21 '25 06:03 ruinabyss