Ubuntu

ssh 登錄時找不到命令“+ virtualenvwrapper 錯誤(Ubuntu 18.04 x64)

  • October 16, 2019

當使用 ssh 密鑰登錄我的 VPS 時,我得到了這個:

Command '' not found, but can be installed with:

sudo apt install libpam-mount      
...           
sudo apt install nmh               

virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON= and that PATH is
set properly.

這是我的.bashrc變數:

export WORKON_HOME=~/Env
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

我試過的

  • 採購.bashrc~/.profile/usr/local/bin/virtualenvwrapper.sh(沒有錯誤)
  • 升級virtualenvwrapperpip3 --upgrade最新)

此外,我的 virtualenv 工作完美。

在腳本的第47-51 行virtualenvwrapper.sh它首先檢查是否VIRTUALENVWRAPPER_PYTHON設置了環境變數,如果沒有,則在第 50 行設置它:

VIRTUALENVWRAPPER_PYTHON="$(command \which python)"

問題是較新版本的 Ubuntu(18.04+)不再python安裝二進製文件,只有python3. 更改python為腳本python3第 50 行,一切就緒;)

否則,在 中.bashrc,您需要設置VIRTUALENVWRAPPER_PYTHON,然後再source設置腳本:

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

簡而言之,virtualenvwrapper.sh是 Python 包的一部分。

我在新的 Ubuntu 18.04 安裝中遇到了這個問題。我在一台舊機器上檢查了我的日誌,發現以下內容:

sudo -H pip3 install virtualenvwrapper
sudo -H pip  install virtualenvwrapper

當我在新機器上執行它們時,錯誤消息消失了。

引用自:https://unix.stackexchange.com/questions/499374