安装:
virtualenvwrapper
找到路径:
[email protected]:/home/lcg# sudo find / -name virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh
修改.bashrc:
[email protected]:/home/lcg# vi ~/.bashrc
最后面加入以下内容后wq保存:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
刷新以下 :
[email protected]:~# source ~/.bashrc
然后就可以创建虚拟环境了:
[email protected]:~# mkvirtualenv py2scrapy
可以看一下创建结果:
(py2scrapy) [email protected]:/# cd ~/.virtualenvs/ (py2scrapy) [email protected]:~/.virtualenvs# ls get_env_details postdeactivate postrmvirtualenv premkproject py2scrapy initialize postmkproject preactivate premkvirtualenv postactivate postmkvirtualenv predeactivate prermvirtualenv
创建Python3的虚拟环境:
(py2scrapy) [email protected]:~/.virtualenvs# deactivate [email protected]:~/.virtualenvs# workon py2scrapy [email protected]:~/.virtualenvs# mkvirtualenv --python==/user/bin/python3 py3scrapy
时间: 2024-10-06 02:14:46