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

 

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

Ubuntu18.04安装virtualenv

 

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

  

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

相关文章:

  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-06-11
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-04-02
  • 2021-10-01
相关资源
相似解决方案