繁体   English   中英

ImportError:没有名为tzwhere的模块

[英]ImportError: No module named tzwhere

我使用Python 2.7在AWS EC2实例上安装了tzwhere并:

pip install tzwhere

当我在安装了它的“ /opt/python/run/venv/lib/python2.7/site-packages”中将其导入Python时,它可以工作,但无法在其他任何地方导入它。 我在系统路径中添加了“ /opt/python/run/venv/lib/python2.7/site-packages”,但这没有帮助。 如果您指导我如何解决此问题,我将不胜感激。

让我解释更多细节:我正在Amazon Elastic Beanstalk上部署Django 1.6项目。 部署项目时,只需要一次导入tzwhere即可。 所以我将其导入到setting.py中。 当我激活虚拟环境时(在本文中有解释),我能够在python中导入tzwhere,但是当我运行时:

sudo python manage.py schemamigration southtut --initial

它返回以下错误消息:

ImportError: Could not import settings 'JoinWikipedians.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named tzwhere

当我停用虚拟环境时,导入tzwhere会返回导入错误。 另外,在任何python环境中,当我使用时:

sys.path.append('/opt/python/run/venv/lib/python2.7/site-packages')

我可以导入tzwhere,但是在我的setting.py中导入tzwhere之前的相同代码无济于事。

我找到了解决方案。 问题在于,AWS EC2的pip install tzwhere存在一些问题。 每当我尝试安装它时,它都会返回内存错误消息。 我完全删除了它,并使用以下方法安装了pytzwhere:

git clone --recursive https://github.com/pegler/pytzwhere.git
python setup.py install

现在,它可以完美运行了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM