Python 3.7.7导入错误:无法从“LSHash”导入名称“LSHash”

2024-04-20 10:20:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python 3.7.7。我有一个类定义为

class LSHash(object):
  def __init__(self, hash_size, input_dim, num_hashtables=1,
             storage_config=None, matrices_filename=None, overwrite=False):
  #...

当我尝试使用从lshash模块导入Python类LSHash

from lshash import LSHash

我有一个ImportError

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    from lshash import LSHash
ImportError: cannot import name 'LSHash' from 'lshash' (/Users/loretoparisi/Documents/MyProjects/lshash/lshash/__init__.py)

未来的lshash.py进口:

from __future__ import print_function, unicode_literals, division, absolute_import
from builtins import int, round, str,  object  # noqa
from future import standard_library
standard_library.install_aliases()  # noqa: Counter, OrderedDict, 
from past.builtins import basestring   # noqa:

import future        # noqa
import builtins      # noqa
import past          # noqa
import six           # noqa

再现错误的代码是here


Tags: frompyimportnoneobjectinitlibraryfuture