【发布时间】:2019-05-06 15:03:04
【问题描述】:
我想将 algolia python lib 导入我的 python 3 应用引擎项目。
原来如此
pip install algoliasearch -t lib
在我的 lib 文件夹中,我创建了 __init__.py
然后在我的项目中我使用导入
from lib.algoliasearch.search_client import SearchClient
到目前为止一切顺利。但例如在 algolia 库中
lib\algoliasearch\search_client.py
还有如下导入语句:
from algoliasearch.helpers import endpoint, is_async_available
这在我全局安装时有效,否则安装在 lib 文件夹中,当我部署应用引擎时它不起作用。
作为解决方案,我可以更新这些文件
from lib.algoliasearch.helpers import endpoint, is_async_available
这是一个糟糕的解决方案。
另一方面,如果我申请:
import sys
sys.path.insert(0, './lib')
这一次,它在几个部分被打破,即
libcrypto_path = find_library(b'crypto' if sys.version_info < (3,) else 'crypto')
if not libcrypto_path:
raise LibraryNotFoundError('The library libcrypto could not be found')
在
lib\asn1crypto\_perf\_big_num_ctypes.py
如何正确导入这个 algoliasearch 库?
注意:我猜,Algolia 团队应该通过提供相关路径来更新他们的包,例如:
而不是
from algoliasearch.helpers import endpoint, is_async_available
这个:
from helpers import endpoint, is_async_available
【问题讨论】:
-
您是否按照此处的说明创建了 app_config.py 文件? cloud.google.com/appengine/docs/standard/python/tools/…
-
这适用于 python 2.7。我正在使用 python 3.7
-
你能显示实际的导入错误(最好是完整的回溯)吗?
-
@DanCornilescu 没有堆栈跟踪但错误显示
- __exception_info {'exception': ModuleNotFoundError(...asearch'"), 'exception_type': <class 'ModuleNotFoundError'>, 'message': "No module named 'al...iasearch'"} dict
标签: python-3.x google-app-engine google-cloud-platform instantsearch