35
votes

I'm trying to install package with pip on Ubuntu server:

$ pip install MySQLdb
Downloading/unpacking MySQLdb
Killed

And it's getting killed. There is enough free RAM on server. Why it is killed?

UPD Logs:

Out of memory: Kill process 6627 (pip) score 297 or sacrifice child

Thats strange, because I have about 150 mb free RAM.

3
Anything in /var/log/kern.log? Or run tail -f /var/log/kern.log and try installing again. - Padraic Cunningham
On another note the package name is actually mysql-python but that does not explain your output - Padraic Cunningham
did you solve the issue? - Padraic Cunningham

3 Answers

6
votes

You have to check logs, depending on the version of ubuntu and stuff, it should be in /var/log/messages or at least in /var/log so you can grep python or pip in that folder. This should provide hints.

Also, if you're not in a virtualenv, you should probably use sudo to perform (implicit) privileged operations, such as copying the library in the global lib folder.

117
votes

If you are running low on memory you could try with pip install package --no-cache-dir

2
votes

If the --no-cache-dir flag isn't enough, try increasing the swap space.

I was trying to install PyTorch on a Linode server which had 2GB RAM and 512 of Swap space. Adding 2GB of Swap space solved the issue.

Method # 3 : Create a swap file.

  1. Create a swap file on the current File system for example on root, for this a new Directory can be created. $ sudo mkdir /swap
  2. Create a new file into this new directory, in this example a new file for 2Gb is create. $ sudo dd if=/dev/zero of=/swap/swapfile1 bs=1M count=2048
  3. Create a new swap area on the file that has been created. $ sudo mkswap /swap/swapfile1
  4. Change the permissions on the file. $ sudo chmod 600 /swap/swapfile1
  5. Add the swap partition to the /etc/fstab file as indicated below on this step: /swap/swapfile1 swap swap defaults 0 0
  6. Load the new swap space that had been created for the Instance. $ sudo swapon -a

Source for Guide: TheGeekDiary