0

I installed tzwhere on an AWS EC2 instance using Python 2.7 and:

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. I added "/opt/python/run/venv/lib/python2.7/site-packages" to my system path, but it did not help. 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. I need to import tzwhere only once when I deploy the project. So I imported it in setting.py. When I activate the virtual environment (explained in this post), I am able to import tzwhere in python, but when I run:

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. In addition, in any python environment, when I use:

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.

Community
  • 1
  • 1
1man
  • 5,216
  • 7
  • 42
  • 56

1 Answers1

0

I found the solution. The problem was that AWS EC2 has some problem with pip install tzwhere. Whenever I tried to install it, it returned the memory error message. I completely removed it and installed pytzwhere, using:

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

Now it works perfectly.

1man
  • 5,216
  • 7
  • 42
  • 56