lru_cache icon indicating copy to clipboard operation
lru_cache copied to clipboard

Problem in importing LruCache

Open agn-7 opened this issue 6 years ago • 4 comments

I installed lru_cache properly with $ pip install lru_cache

$ pip show lru_cache
Name: lru-cache
Version: 0.2.3
Summary: thread safe lru cache
Home-page: https://github.com/acmerfight/lru_cache
Author: acmerfight
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.6/dist-packages

But when I importing this library, encountered with this error:

In [1]: from cache import LruCache
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-2bf864cf4d52> in <module>()
----> 1 from cache import LruCache

/usr/local/lib/python3.6/dist-packages/cache/__init__.py in <module>()
----> 1 from lru_cache import LruCache

ModuleNotFoundError: No module named 'lru_cache'

agn-7 avatar Oct 28 '18 14:10 agn-7

Are you running Python 3?

It is probably a problem with relative path.

I got it working by modifying __init__.py to have relative path:

-  from lru_cache import LruCache
+ from .lru_cache import LruCache

syutbai avatar Nov 17 '19 13:11 syutbai

不兼容 python3 @acmerfight :doge:

alingse avatar Feb 12 '20 07:02 alingse

solved

acmerfight avatar Feb 27 '20 15:02 acmerfight

@acmerfight However, the problem still remains. Please check the pull request on your repo.

agn-7 avatar Mar 01 '20 07:03 agn-7