Trouble installing scipy in virtualenv on a amazon ec2 linux micro instance Trouble installing scipy in virtualenv on a amazon ec2 linux micro instance python python

Trouble installing scipy in virtualenv on a amazon ec2 linux micro instance


One solution is to temporarily enable swap on your micro instance. As described at this SO post, enable 1gb swap via:

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024sudo /sbin/mkswap /var/swap.1sudo /sbin/swapon /var/swap.1

Once swap is on, install scipy via pip:

sudo apt-get install -y libatlas-base-dev gfortran python-dev build-essential g++sudo pip install numpysudo pip install scipy

Once scipy successfully installs, you can disable it via:

sudo swapoff /var/swap.1sudo rm /var/swap.1


This worked for me:

pip --no-cache-dir install scipy

See:

note:

  • works for other service providers, hardware, VMs, and containers.
  • if RAM allocation size of 1GB
  • just calculate the diff between the cached directory memory usage and available ram


Yes, 512MB is not enough for compiling that C++ file.

Your best option is to build Scipy as a binary package (bdist, or eggs, or, more modern wheels) e.g. via python setupegg.py bdist_egg on a different machine with compatible environment. For instance, use a similar Linux version to the EC2 instance in a virtual machine.

In general, it's good to remember that when pip installs packages, it compiles source files. If the package is not tiny, this is inefficient and it's better to use binary packages. The wheel package format is supposed to play well together with pip.