Python Forum
can not import name invalidate_caches
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can not import name invalidate_caches
#1
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
Reply
#2
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?
Reply
#3
I have the same error in python3.5.
Reply
#4
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).

>>>
Reply
#5
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
>>> 
Reply
#6
[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?
Reply
#7
Is this issue raised by you?
Reply
#8
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#9
(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)
Reply
#10
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?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020