我正在使用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
您可以在
__init__
.py文件中进行相对导入,如下所示:Intra-package References
Good example
相关问题 更多 >
编程相关推荐