Python Forum
can not import name invalidate_caches - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: can not import name invalidate_caches (/thread-3129.html)

Pages: 1 2


can not import name invalidate_caches - Bani - Apr-30-2017

Hi,
I use Python 2.7. I have an Import Error: can not import name invalidate_caches. What should I do? 

from importlib import invalidate_caches



RE: can not import name invalidate_caches - nilamo - Apr-30-2017

https://docs.python.org/2.7/library/importlib.html

(Apr-30-2017, 04:37 PM)Bani Wrote: Hi,
I use Python 2.7. ... What should I do? 

Upgrade to a version of python which has that module?


RE: can not import name invalidate_caches - Bani - May-01-2017

I have the same error in python3.5.


RE: can not import name invalidate_caches - nilamo - May-01-2017

Mind showing the full traceback?  I'm on 3.6, so I can't replicate exactly what you're on, but it seems to work on my end.

D:\Projects\playground>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib import invalidate_caches
>>> invalidate_caches()
>>> help(invalidate_caches)
Help on function invalidate_caches in module importlib:

invalidate_caches()
   Call the invalidate_caches() method on all meta path finders stored in
   sys.meta_path (where implemented).

>>>



RE: can not import name invalidate_caches - buran - May-01-2017

No problem with Python 3.5.2

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib import invalidate_caches
>>> 



RE: can not import name invalidate_caches - Bani - May-01-2017

[Image: h2ug_screen_shot_2017-05-01_at_12.17.27_pm.png][Image: gz3x_screen_shot_2017-05-01_at_12.14.35_pm.png]
Does it need to install special package?


RE: can not import name invalidate_caches - buran - May-01-2017

Is this issue raised by you?


RE: can not import name invalidate_caches - wavic - May-01-2017

I get this with Python 2

~ ❯❯❯ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib import invalidate_caches
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name invalidate_caches



RE: can not import name invalidate_caches - buran - May-01-2017

(May-01-2017, 08:36 AM)wavic Wrote: I get this with Python 2
Did you read post#2 by nilamo?

Also OP is now running python 3.5. (as per the screenshot he provided - Interpreter settings)


RE: can not import name invalidate_caches - nilamo - May-01-2017

You didn't happen to name one of your files "importlib.py", did you?

The error is saying that the file is found, but that the function doesn't exist within it. Since importlib is part of the standard library, maybe the file's being shadowed somewhere?