简体   繁体   English

ImportError:没有名为tzwhere的模块

[英]ImportError: No module named tzwhere

I installed tzwhere on an AWS EC2 instance using Python 2.7 and: 我使用Python 2.7在AWS EC2实例上安装了tzwhere并:

pip install tzwhere

When I import it in Python at "/opt/python/run/venv/lib/python2.7/site-packages", where it is installed, it works, but I cannot import it anywhere else. 当我在安装了它的“ /opt/python/run/venv/lib/python2.7/site-packages”中将其导入Python时,它可以工作,但无法在其他任何地方导入它。 I added "/opt/python/run/venv/lib/python2.7/site-packages" to my system path, but it did not help. 我在系统路径中添加了“ /opt/python/run/venv/lib/python2.7/site-packages”,但这没有帮助。 I'll appreciate it if you guide me how to solve this problem. 如果您指导我如何解决此问题,我将不胜感激。

Let me explain more details: I am deploying a Django 1.6 project on Amazon Elastic Beanstalk. 让我解释更多细节:我正在Amazon Elastic Beanstalk上部署Django 1.6项目。 I need to import tzwhere only once when I deploy the project. 部署项目时,只需要一次导入tzwhere即可。 So I imported it in setting.py. 所以我将其导入到setting.py中。 When I activate the virtual environment (explained in this post ), I am able to import tzwhere in python, but when I run: 当我激活虚拟环境时(在本文中有解释),我能够在python中导入tzwhere,但是当我运行时:

sudo python manage.py schemamigration southtut --initial

It returns the following error message: 它返回以下错误消息:

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

When I deactivate the virtual environment, importing tzwhere returns the import error. 当我停用虚拟环境时,导入tzwhere会返回导入错误。 In addition, in any python environment, when I use: 另外,在任何python环境中,当我使用时:

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

I can import tzwhere, but the same code before importing tzwhere in my setting.py does not help. 我可以导入tzwhere,但是在我的setting.py中导入tzwhere之前的相同代码无济于事。

I found the solution. 我找到了解决方案。 The problem was that AWS EC2 has some problem with pip install tzwhere. 问题在于,AWS EC2的pip install tzwhere存在一些问题。 Whenever I tried to install it, it returned the memory error message. 每当我尝试安装它时,它都会返回内存错误消息。 I completely removed it and installed pytzwhere, using: 我完全删除了它,并使用以下方法安装了pytzwhere:

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

Now it works perfectly. 现在,它可以完美运行了。

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

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