rav*_*viv 2 python django python-module elementtree
在我的Django项目中,以下行抛出一个ImportError:"没有名为elementtree的模块".
from elementtree import ElementTree
Run Code Online (Sandbox Code Playgroud)
但是,安装了模块(即,我可以运行交互式python shell,并输入没有任何ImportError的确切行),并且包含该模块的目录位于PYTHONPATH上.但是当我访问浏览器中的任何页面时,它以某种方式找不到该模块,并抛出ImportError.可能是什么导致了这个?
你能elementtree在django shell中导入:
python manage.py shell
Run Code Online (Sandbox Code Playgroud)
假设您有多个python版本并且不知道哪个版本用于运行您的站点,请将以下内容添加到您的视图并推python_ver送到您的模板,它将显示您正在使用的Python版本:
import sys
python_ver = sys.version
Run Code Online (Sandbox Code Playgroud)
您还可以在以下代码中以编程方式显式添加elementtree的路径settings.py:
import sys
sys.path.append('path to where elementtree resides')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6819 次 |
| 最近记录: |