python - Django-无法导入文件

标签 python django django-views

我正在尝试从views.py导入python文件Project/MasterCard/src/Gnip.py

import sys
import os
import ConfigParser
from MasterCard.src 
import Gnip #  -- > Here i want to import the Gnip.py

发生的异常:

Exception Value:    No module named src

my directory structure

最佳答案

试试这个

在里面创建一个__init__.py作为MasterCard/src/__init__.py。然后导入

from MasterCard.src import Gnip

关于python - Django-无法导入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35647816/

相关文章:

django - 如何在Django中设置cookie然后渲染模板?

python - Django url 警告 urls.W002

django - django 1.5 CBV 中返回 HttpResponse 时出现 simplejson 错误

python - 通过id获取对象时出现ValueError

python - Split() 函数给我带来了麻烦

python - python中的循环依赖

python - 让所有用户都可以使用本地安装的 anaconda,而无需重新安装所有用户

python - 通过更大的矩阵迭代子矩阵

python - Django .all() 对 unique_together 模型进行查询

python - 检查文本是否以空格开头