Ubuntu18.04安装virtualenv

Ubuntu18.04,默认自带python2和python3,如果只想安装python3环境下的virtualenv,可以采用下面的方法

1. pip3 install virtualenv

2. pip3 install virtualenvwrapper

3.mkdir $HOME/.virtualenvs

4.vim  ~/.bashrc

   在文本的最后添加:

      export WORKON_HOME=$HOME/.virtualenvs

      export PROJECT_HOME=$HOME/ENV

      source ~/.local/bin/virtualenvwrapper.sh

     Ubuntu18.04安装virtualenv_第1张图片

 

但是以上操作完成后,每次打开终端,都会出现如下界面

Ubuntu18.04安装virtualenv_第2张图片

 

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

sudo apt install libpam-mount      
sudo apt install openssh-server    
sudo apt install openvswitch-common
sudo apt install openvswitch-switch
sudo apt install php-common        
sudo apt install bpfcc-tools       
sudo apt install burp              
sudo apt install cryptmount        
sudo apt install dolphin-emu       
sudo apt install mailutils-mh      
sudo apt install mmh               
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.
 

并且此时用workvirtualenv 命令无法创建虚拟空间,这主要是因为,我们配置的是python3下的虚拟环境,但是系统还是默认调用python2的配置文件,但是python2我们并没有配置,所以我们要修改配置文件

5. cd .local/bin

     vim virtualenvwrapper.sh

     在文件中将VIRTUALENVWRAPPER_PYTHON="$(command \which python)"改为            VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
 

   Ubuntu18.04安装virtualenv_第3张图片

  

完成以上5步,虚拟环境便可以正常使用了

你可能感兴趣的:(Python)