Conda Creating a virtual Environment 1. View Packages
conda list
See which packages are installed
conda env list
See what virtual environments are available
conda -V
View the version of Conda
2. Create a virtual environment, named
myflaskapp
,
n
means that
name
; and install
flask
Package.
Note that the Conda create command requires so you give it the name of the a package to install in the new environment.
conda
command to create a virtual environment, you must specify one or more of the ones you need to install package
.
conda create -n py2 python=2* anaconda
This will install the ANACONDA2 version.
Chestnut 1:
This command installs a myflaskapp
package named virtual Environment flask
.
create -n myflaskapp flask
Chestnut 2:
This is the clone that created the same Python environment as the original system, named nb
.
create -n nb --clone root
Chestnut 3:
There's no need to specify a specific package.
create --name $ENVIRONMENT_NAME python
Other:
create -n py3 python=3*$ conda create -n py2 python=2*
This would create the environments, one with Python3 and the other with Python2. I typically set one of these as my default by adding source activate Py3 to my terminal startup. Typically I only use these ' named Python ' environments to run a Python REPL or does general Python tasks. I ' ll create another Conda environment named specifically for each real project I work on.
This creates an environment of two Python versions.
3. Switching the environment
The Linux command was not tested.
- Linux:
source activate myflaskapp
- Windows:
activate myflaskapp
Picture description
4. Close the Environment
- Linux:
source deactivate
- Windows:
deactivate
5. Change the specified virtual environment installation package
install -n yourenvname [package]
6. Removing a virtual environment
All of these virtual environments are under the C:\Anaconda3\envs
folder.
Virtualenv Creating a Virtual Environment 1. Install Virtualenv
install virtualenv
2. Create a virtual environment
$ mkdir myproject$ cd myproject$ virtualenv venv
Create a myproject
folder named, and then create a virtual environment here venv
.
The virtualenv of adding options when creating virtualenv --no-site-packages
will not read the system package, as follows:
virtualenv nowamagic_venv --no-site-packages
--distribute
Option enables virtualenv to use the new release-based package management system rather than the Setuptools-acquired package. All you need to know now is that the--distribute option automatically installs PIP in the new virtual environment, so you don't need to install it manually. When you become a more experienced Python developer, you will understand the details.
--distribute nowamagic_venv
3. Activating the virtual environment
- Linux:
$ . venv/bin/activate
orsource $ENV_BASE_DIR/$ENVIRONMENT_NAME/bin/activate
No experiments, so temporarily write two methods, if you go to the venv
Virtual Environment folder, you cansource bin/activate
- Windows:
$ venv\scripts\activate
4. Exit the Environment
deactivate
Resources
- Using Continuum Analytics Conda as a replacement for virtualenv, Pyenv, and more!
- Conda vs. Pip vs. virtualenv
- Create virtual environments for Python with Conda
- Conda-documention
- Flask-virtualenv Introduction
- Switching between Anaconda and Anaconda3
- Managing the Python development environment with Conda
- Build multiple Python independent development environments with VIRTUALENV
- Python Scientific Computing Environment recommendation--anaconda
Wen/michael_ Xiang _ (Jane book author)
Original link: http://www.jianshu.com/p/ab93973286cc
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".
Anacodna Conda and Virtualenv use tutorials to create a virtual environment