2

On an AWS EC2, I cloned pytzwhere using:

sudo git clone --recursive https://github.com/pegler/pytzwhere.git

Then I tried to install it using Python 2.7 and:

sudo python setup.py install

Unfortunately it stops with the following error:

...
Extracting tzwhere-2.2-py2.7.egg to /usr/local/lib/python2.7/site-packages
Traceback (most recent call last):
  File "setup.py", line 32, in <module>
    'Topic :: Software Development :: Localization',
  File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 623, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 672, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 820, in install_eggs
    return [self.install_egg(dist_filename, tmpdir)]
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 900, in install_egg
    os.path.dirname(destination)))
  File "/usr/lib64/python2.7/distutils/cmd.py", line 349, in execute
    util.execute(func, args, msg, dry_run=self.dry_run)
  File "/usr/lib64/python2.7/distutils/util.py", line 309, in execute
    func(*args)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1177, in unpack_and_compile
    unpack_archive(egg_path, destination, pf)
  File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 50, in unpack_archive
    driver(filename, extract_dir, progress_filter)
  File "/usr/lib/python2.7/dist-packages/setuptools/archive_util.py", line 117, in unpack_zipfile
    data = z.read(info.filename)
  File "/usr/lib64/python2.7/zipfile.py", line 935, in read
    return self.open(name, "r", pwd).read()
  File "/usr/lib64/python2.7/zipfile.py", line 630, in read
    data = self.read1(n)
  File "/usr/lib64/python2.7/zipfile.py", line 684, in read1
    max(n - len_readbuffer, self.MIN_READ_SIZE)
MemoryError

I'll appreciate it if you guide me how to solve this problem.

1man
  • 5,216
  • 7
  • 42
  • 56
  • Try using a virtual environment and pytzwhere from PyPI. Also, make sure that you have shapely and libgeos installed from Ubuntu as well. I used the following: `virtualenv venv` to make virtual env, `source venv/bin/activate` to activate it, `sudo apt-get install libgeos-dev libgeos-c1` to install the required libraries and `pip install shapely tzwhere` and it worked for me. There is an issue with installing some libraries on ec2 due to memory limitations. See this [SO Q/A](http://stackoverflow.com/questions/19595944/trouble-installing-scipy-in-virtualenv-on-a-amazon-ec2-linux-micro-instance). – Mark Mikofski Jan 01 '16 at 23:55
  • The issue you're hitting is because it's trying to download setuptools. This is a classic reason why you should not use `sudo` to install Python packages into a Linux system. Instead use [`python setup.py install --user`](https://docs.python.org/2/install/#alternate-installation-the-user-scheme) or as I recommended above use a virtual environment. You can install `virtualenv` using `sudo apt-get install python-virtualenv`. If you need the system packages use the [system site packages option](https://virtualenv.readthedocs.org/en/latest/reference.html#cmdoption--system-site-packages) – Mark Mikofski Jan 02 '16 at 00:00
  • @Mark Mikofski, happy new year and thank you for your detailed comment. I am on AWS Linux, which I think is Fedora. I tried sudo yum install libgeos-dev libgeos-c1. It returned No package libgeos-dev available. No package libgeos-c1 available. Error: Nothing to do. – 1man Jan 02 '16 at 00:09
  • @Mark Mikofski, also, when I tried python setup.py install --user in my virtual environment, it returned the following: running install Checking .pth file support in /home/ec2-user/.local/lib/python2.7/site-packages/ /opt/python/run/venv/bin/python -E -c pass TEST FAILED: /home/ec2-user/.local/lib/python2.7/site-packages/ does NOT support .pth files error: bad install directory or PYTHONPATH ... – 1man Jan 02 '16 at 00:14
  • Sorry for assuming Ubuntu and happy new year to you too. Looks like [Fedora maintainers have a shapely build in their package db](https://admin.fedoraproject.org/pkgdb/package/rpms/python-shapely/). Try `yum install python-shapely` it should install libgeos and whatever other dependencies you have. – Mark Mikofski Jan 02 '16 at 00:14
  • @Mark Mikofski, ... You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /home/ec2-user/.local/lib/python2.7/site-packages/ and your PYTHONPATH environment variable currently contains: '/opt/python/current/app/:/opt/python/current/app/:/opt/python/current/app/:/opt/python/current/app/:/opt/python/current/app/:' – 1man Jan 02 '16 at 00:15
  • Sorry my apologies for introducing two different solutions simultaneously. Please do one or the other. Either (A) use the `--user` scheme _outside_ a virtuan env, or (B) install as usual _inside_ a virtual env, but not both. – Mark Mikofski Jan 02 '16 at 00:15
  • @Mark Mikofski, Unfortunately, "sudo yum install python-shapely" in my virtual environment returns the same thing: No package python-shapely available. Error: Nothing to do – 1man Jan 02 '16 at 00:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/99490/discussion-between-mark-mikofski-and-user2521204). – Mark Mikofski Jan 02 '16 at 00:18
  • @Mark Mikofski, Hey 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 pytzwhere, and installed pytzwhere again. Now it works perfectly. Thank you so much for your time and concern. – 1man Jan 02 '16 at 13:25

0 Answers0