當前位置: 首頁>>技術教程>>正文


python – 在Ubuntu服務器上安裝軟件包的內存不足問題

, , , ,

問題描述

我正在使用具有512MB RAM和20 GB HDD的Ubuntu雲服務器。它的450MB + RAM已被進程使用。

我需要安裝一個名為lxml的新軟件包,該軟件包在安裝時會使用Cpython進行編譯,這是一個非常繁瑣的過程,因此始終會以錯誤gcc: internal compiler error: Killed (program cc1)退出,這是由於沒有可用的RAM來運行。

升級計算機是一種選擇,但是它有其自身的問題,很少有服務/網站可以從此服務器上運行。

但是在我的本地計算機上,lxml已正確安裝。而且由於我隻需要lxml,那麽是否有可能從本地計算機的目錄中選擇所有有用的文件然後複製到遠程計算機中?

這樣行嗎?如果是,如何對一個軟件包的所有文件進行pick-up處理?

問候

最佳回答

通過添加交換文件來擴展RAM:http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

a swap file is a file stored on the computer hard drive that is used as a temporary location to store information that is not currently being used by the computer RAM. By using a swap file a computer has the ability to use more memory than what is physically installed in the computer http://www.computerhope.com/jargon/s/swapfile.htm

簡而言之:

  1. 以root用戶身份登錄:su -或使用前麵的sudo執行命令

  2. dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

  3. mkswap /swapfile1

  4. chown root:root /swapfile1

  5. chmod 0600 /swapfile1

  6. swapon /swapfile1

現在,交換文件將被臨時激活,但在重新啟動後將消失。您應該有足夠的RAM用於安裝過程

刪除文件:

  1. swapoff -v /swapfile1

  2. rm /swapfile1

參考資料

本文由Ubuntu問答整理, 博文地址: https://ubuntuqa.com/zh-tw/article/10332.html,未經允許,請勿轉載。