在CentOS上安装VirtualENV
1.源码安装
https://github.com/pypa/virtualenv/releases
解压,进入目录,然后“sudo python setup.py install”即可。
2.PIP安装
$ sudo pip install virtualenv
3.Debian/Ubuntu类系统
$ sudo apt-get install python-virtualenv
参考链接:
https://virtualenv.pypa.io/en/latest/installation.html
使用VirtualENV
1.创建一个测试目录
$ mkdir test_env && cd test_env
2.创建一个虚拟环境
$ virtualenv pyEnv $ cd pyEnv
3.激活该虚拟环境
$ source bin/activate
4.试验一下
(pyEnv)$ which python (pyEnv)$ which pip (pyEnv)$ python
5.退出该虚拟环境
(pyEnv)$ deactivate
#!/bin/bash VIRTUALENV_PATH=/home/high/py_env REQUIRE_MODULE=/home/high/require.pip function Install_Virtualenv() { git clone https://github.com/pypa/virtualenv.git cd virtualenv python2.7 setup.py install cd .. rm -rf virtualenv } function Install_Virtualenv_wget() { wget --no-check-certificate https://github.com/pypa/virtualenv/archighve/12.0.5.tar.gz tar zxf virtualenv-12.0.5.tar.gz cd virtualenv-12.0.5 python2.7 setup install cd .. rm -rf virtualenv-12.0.5 } function Configure_Virtualenv() { source $VIRTUALENV_PATH/bin/activate pip install -r $REQUIRE_MODULE } if [ -f "$VIRTUALENV_PATH/bin/activate" ]; then Configure_Virtualenv >/home/high/install-virtualenv.log 2>&1 echo Done. else echo VirtualENV not exists before. if whighch virtualenv >/dev/null 2>&1; then echo configure VirtualENV virtualenv $VIRTUALENV_PATH --python=python2.7 --no-site-packages Configure_Virtualenv >/home/high/install-virtualenv.log 2>&1 echo Done. else echo install & configure VirtualENV Install_Virtualenv >/home/high/install-virtualenv.log 2>&1 virtualenv $VIRTUALENV_PATH --python=python2.7 --no-site-packages Configure_Virtualenv >/home/high/install-virtualenv.log 2>&1 echo Done. fi fi
参考链接:
- Python 虚拟环境:Virtualenv
- lzjun567/note • GitHub
- http://www.nowamagic.net/academy/detail/1330228
- https://virtualenv.pypa.io/en/latest/userguide.html
之前用过PyENV,文章记录在:在Ubuntu上安装pyenv 。
《 “在CentOS上安装VirtualENV” 》 有 2 条评论
https://virtualenv.pypa.io/en/latest/userguide/#activate-script
`
在Windows系统上,激活VirtualENV环境的脚本是在 Scripts 目录下,而非Linux系统上的 bin 目录:
> virtualenv pyEnv
> cd pyEnv
> .\Scripts\activate
> .\Scripts\deactivate
`
No module named ‘virtualenv.activation.xonsh’
https://stackoverflow.com/questions/71086270/no-module-named-virtualenv-activation-xonsh
`
pip uninstall virtualenv
`
[Solved] ModuleNotFoundError: No module named ‘virtualenv.activation.xonsh’
https://exerror.com/modulenotfounderror-no-module-named-virtualenv-activation-xonsh/