ImportError:没有名为tzwhere

时间:2016-01-01 23:26:41

标签: python amazon-web-services import module pytz

我使用Python 2.7和

在AWS EC2实例上安装了tzwhere
pip install tzwhere

当我在Python中导入它时," /opt/python/run/venv/lib/python2.7/site-packages" ;,安装它的地方,它可以工作,但我不能在任何地方导入它其他。我添加了" /opt/python/run/venv/lib/python2.7/site-packages"到我的系统路径,但它没有帮助。 如果你指导我如何解决这个问题,我会很感激。

让我解释一下更多细节:我正在Amazon Elastic Beanstalk上部署Django 1.6项目。部署项目时,我只需要导入一次tzwhere。所以我在setting.py中导入了它。当我激活虚拟环境(在this post中解释)时,我能够在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之前的相同代码没有帮助。

1 个答案:

答案 0 :(得分:0)

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

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

现在它完美无缺。

相关问题