Go to your project directory then open terminal or open terminal in VSCode then put this command
conda activate myenv1
If the environment is activated, it will be shown in left part of your bash prompt like
(myenv1) username: /path/to / project $
Then,
python my_script.py
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. You can also share an environment file.,For example, if you create an environment and install Python and a package:,To install additional conda packages, it is best to recreate the environment.,To create an environment with a specific version of Python and multiple packages:
conda create--name myenv
proceed([y] / n) ?
conda create - n myenv python = 3.9
conda create - n myenv scipy
conda create - n myenv python conda install - n myenv scipy
conda create - n myenv scipy = 0.17 .3
A Conda environment is a directory that contains a specific collection of Conda packages that you have installed.,A Conda environment is a directory that contains a specific collection of Conda packages that you have installed. ,The command above will create a new Conda environment called “python3” and install the most recent version of Python. If you wish, you can specify a particular version of packages for conda to install when creating the environment.,If you haven’t done it yet, create a new introduction-to-conda-for-data-scientists directory on your Desktop in order to maintain a consistent workspace for all your conda environment.
$ cd~/Desktop $ mkdir introduction - to - conda - for -data - scientists $ cd introduction - to - conda - for -data - scientists
> cd~\Desktop >
mkdir introduction - to - conda -
for -data - scientists >
cd introduction - to - conda -
for -data - scientists
$ conda create--name python3 - env python
$ conda create--name python36 - env python = 3.6
$ conda search $PACKAGE_NAME
$ conda search scikit - learn
Data Tip: You can also install a package into an environment without activating it by using conda install conda-forge --name myenv package-name,Install the package that you want to add to that environment using either a .yml file or conda install.,Install earthpy into that environment using the conda-forge channel:,You can install a package manually into this environment using conda install. Try the following:
$ conda create - n myenv
$ conda create - n myenv Python = 3.7
$ conda env create - f environment.yml
$ conda env list
$ base * /Users/test / miniconda3
$ myenv / Users / test / anaconda3 / envs / myenv
$ otherenv / Users / test / anaconda3 / envs / otherenv
$ conda activate myenv
February 10, 2022
(i) Create an empty environment
conda create--name {
env_name
}
conda create--name mlenv
(ii) Create an environment + specific python version
conda create--name { env_name } { python == 3.7 .5 } conda create--name mlenv python == 3.7 .5
(iii) Create an environment + specific Python version + packages
conda create--name env_name python == 3.7 .5 package_name1 package_name2
2. Activate the environment
conda activate { env_name }
To deactivate whichever you are currently in, use:
conda deactivate