File "/home/nguyentv/schoollink/web/views/apis.py", line 10, in <module>
from util.redis.redis_client import Redis
ImportError: No module named util.redis.redis_client
When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:
the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
the installation-dependent default.
After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.
您正试图从名为
util
的包导入Redis。除非此包是应用程序的一部分,否则它不存在。你知道吗根据python-redis' documentation,下面是如何导入它:
或者,相当于:
The Module Search Path
基本上,解释器将在当前工作目录中执行查找,然后它将搜索系统定义的库目录。你知道吗
您面临的问题可能是代码正在查找不存在的模块、从错误的目录调用脚本,或者
sys.path
的设置不正确。你知道吗如果您演示如何实例化解释器,
pwd
输出和tree
输出,我可以提供更多帮助。你知道吗相关问题 更多 >
编程相关推荐