$ sudo apt install virtualenv
$ virtualenv Yourfile
报以下错误时可尝试指定python版本:
OSError: Command /home/smartcity/dengjie/bin/python2 - setuptools pkg_resources pip wheel failed with error code 1
$ virtualenv -p python3 Yourfile #可指定python版本
进入虚拟环境:
source ./Yourfile/bin/activate
退出虚拟环境
deactivate
此种方法在虚拟环境中最好使用pip安装其他包
另一种安装虚拟环境的方法参考博客:
https://blog.youkuaiyun.com/qq_38332436/article/details/82022298
https://www.cnblogs.com/lliuye/p/10149932.html
在~/.bashrc最后添加以下两行:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
在命令行
source ~/.bashrc