操作系统:manjaro 17.1.7
python版本:3.6.4
功能需求:创建一个虚拟环境
实现途径:
mkdir nova_virtual_env python -m venv nova_virtual_env
不过很多时候,python3不是一个很好的使用选择:
这时候便需要使用python2了。这里补充一下manjaro上python2虚拟环境的创建方式:
1.先安装python2的一下关于虚拟环境的包:
sudo pacman -S --needed --noconfirm python2-pip python2-setuptools python2-virtualenv python-virtualenvwrapper
2.开始创建虚拟环境:
mkdir nova_virtual_env
python2 -m virtualenv --clear nova_virtual_env
tips:
这里使用 --clear参数是因为之前在nova_virtual_env中已经安装了虚拟环境了,所以这里需要清除下。
神器送上:
扫描二维码关注公众号,回复:
411705 查看本文章
Openstack python2 -m virtualenv --help Usage: virtualenv.py [OPTIONS] DEST_DIR Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose Increase verbosity. -q, --quiet Decrease verbosity. -p PYTHON_EXE, --python=PYTHON_EXE The Python interpreter to use, e.g., --python=python2.5 will use the python2.5 interpreter to create the new environment. The default is the interpreter that virtualenv was installed with (/usr/bin/python2) --clear Clear out the non-root install and start from scratch. --no-site-packages DEPRECATED. Retained only for backward compatibility. Not having access to global site-packages is now the default behavior. --system-site-packages Give the virtual environment access to the global site-packages. --always-copy Always copy files rather than symlinking. --unzip-setuptools Unzip Setuptools when installing it. --relocatable Make an EXISTING virtualenv environment relocatable. This fixes up scripts and makes all .pth files relative. --no-setuptools Do not install setuptools in the new virtualenv. --no-pip Do not install pip in the new virtualenv. --no-wheel Do not install wheel in the new virtualenv. --extra-search-dir=DIR Directory to look for setuptools/pip distributions in. This option can be used multiple times. --download Download preinstalled packages from PyPI. --no-download, --never-download Do not download preinstalled packages from PyPI. --prompt=PROMPT Provides an alternative prompt prefix for this environment. --setuptools DEPRECATED. Retained only for backward compatibility. This option has no effect. --distribute DEPRECATED. Retained only for backward compatibility. This option has no effect.