点安装 - 杀死
pip install - killed
我正在尝试在 Ubuntu 服务器上使用 pip 安装包:
$ pip install MySQLdb
Downloading/unpacking MySQLdb
Killed
它正在被杀死。服务器上有足够的空闲 RAM。为什么会被杀?
更新
日志:
Out of memory: Kill process 6627 (pip) score 297 or sacrifice child
这很奇怪,因为我有大约 150 MB 的空闲 RAM。
你必须检查日志,这取决于 ubuntu 的版本和东西,它应该在 /var/log/messages
或至少在 /var/log
这样你就可以 grep python 或 pip 在该文件夹中。这应该提供提示。
此外,如果您不在 virtualenv 中,您可能应该使用 sudo
来执行(隐式)特权操作,例如复制全局 lib 文件夹中的库。
如果您 运行 内存不足,您可以尝试使用 pip install package --no-cache-dir
如果 --no-cache-dir
标志不够,请尝试增加交换 space。
我试图在具有 2GB RAM 和 512 Swap space 的 Linode 服务器上安装 PyTorch。添加 2GB 的 Swap space 解决了这个问题。
Method # 3 : Create a swap file.
- Create a swap file on the current File system for example on root, for this a new Directory can be created.
$ sudo mkdir /swap
- 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
- Create a new swap area on the file that has been created.
$ sudo mkswap /swap/swapfile1
- Change the permissions on the file.
$ sudo chmod 600 /swap/swapfile1
- Add the swap partition to the /etc/fstab file as indicated below on this step:
/swap/swapfile1 swap swap defaults 0 0
- Load the new swap space that had been created for the Instance.
$ sudo swapon -a
指南来源:TheGeekDiary
第一步:
pip install package --no-cache-dir
如果问题仍然存在,请转到步骤 2。
第 2 步:
sudo swapoff -a
sudo swapon -a
然后重试步骤 1。
在我的例子中,使用 pip3 cache purge
清理 pip 缓存是解决方案,但要小心:它会删除整个 pip 缓存。
我在空闲状态下有足够的空闲 RAM (~3Gb),但安装 torch 一次又一次被终止,甚至没有显示下载进度:
Collecting torch>=1.5.0
Killed
所以我假设,就像@embiem 猜测的那样,我在缓存中损坏了文件,因为我曾经中止了模块依赖项的安装。清除整个 pip 缓存后,安装成功(并且释放了 15GB 的可用磁盘 space - 我使用了很多虚拟环境)。您可以使用 pip3 cache info
和所有缓存管理命令 pip3 cache -h
查看简要信息,这在某些情况下非常有用。
我正在尝试在 Ubuntu 服务器上使用 pip 安装包:
$ pip install MySQLdb
Downloading/unpacking MySQLdb
Killed
它正在被杀死。服务器上有足够的空闲 RAM。为什么会被杀?
更新 日志:
Out of memory: Kill process 6627 (pip) score 297 or sacrifice child
这很奇怪,因为我有大约 150 MB 的空闲 RAM。
你必须检查日志,这取决于 ubuntu 的版本和东西,它应该在 /var/log/messages
或至少在 /var/log
这样你就可以 grep python 或 pip 在该文件夹中。这应该提供提示。
此外,如果您不在 virtualenv 中,您可能应该使用 sudo
来执行(隐式)特权操作,例如复制全局 lib 文件夹中的库。
如果您 运行 内存不足,您可以尝试使用 pip install package --no-cache-dir
如果 --no-cache-dir
标志不够,请尝试增加交换 space。
我试图在具有 2GB RAM 和 512 Swap space 的 Linode 服务器上安装 PyTorch。添加 2GB 的 Swap space 解决了这个问题。
Method # 3 : Create a swap file.
- Create a swap file on the current File system for example on root, for this a new Directory can be created. $ sudo mkdir /swap
- 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
- Create a new swap area on the file that has been created. $ sudo mkswap /swap/swapfile1
- Change the permissions on the file. $ sudo chmod 600 /swap/swapfile1
- Add the swap partition to the /etc/fstab file as indicated below on this step: /swap/swapfile1 swap swap defaults 0 0
- Load the new swap space that had been created for the Instance. $ sudo swapon -a
指南来源:TheGeekDiary
第一步:
pip install package --no-cache-dir
如果问题仍然存在,请转到步骤 2。
第 2 步:
sudo swapoff -a
sudo swapon -a
然后重试步骤 1。
在我的例子中,使用 pip3 cache purge
清理 pip 缓存是解决方案,但要小心:它会删除整个 pip 缓存。
我在空闲状态下有足够的空闲 RAM (~3Gb),但安装 torch 一次又一次被终止,甚至没有显示下载进度:
Collecting torch>=1.5.0
Killed
所以我假设,就像@embiem 猜测的那样,我在缓存中损坏了文件,因为我曾经中止了模块依赖项的安装。清除整个 pip 缓存后,安装成功(并且释放了 15GB 的可用磁盘 space - 我使用了很多虚拟环境)。您可以使用 pip3 cache info
和所有缓存管理命令 pip3 cache -h
查看简要信息,这在某些情况下非常有用。