Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install - killed

Tags:

python

pip

ubuntu

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.

like image 230
artem Avatar asked May 30 '15 19:05

artem


5 Answers

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

like image 157
Joaquín Avatar answered Nov 17 '22 05:11

Joaquín


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.

like image 38
Aif Avatar answered Nov 17 '22 06:11

Aif


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

like image 10
Navan Chauhan Avatar answered Nov 17 '22 06:11

Navan Chauhan


In my case the cleaning cache of pip by using pip3 cache purge was was the solution, but be careful: it removes the entire pip cache.

I have enough free RAM in idle state (~3Gb) but installation of torch being killed again and again, even without showing downoading progress:

Collecting torch>=1.5.0
Killed

So I supposed, just like @embiem guessed, that I had corrupted files in the cache, because I had aborted installation of the dependencies for the module once. After clearing the whole pip cache the installation was successful (And 15GB of free disk space was freed up - I use a lot of virtual environments). You can check brief info with pip3 cache info and all cache managing command pip3 cache -h, it's very useful in some cases.

like image 7
ferrum Avatar answered Nov 17 '22 06:11

ferrum


Step1:

pip install package --no-cache-dir If the problem persists, go to step 2.

Step2:

sudo swapoff -a

sudo swapon -a

Then try step 1 again.

like image 4
ambition_sky Avatar answered Nov 17 '22 05:11

ambition_sky