Conda is the default package and environment management tool shipped with Anaconda.
This post logs my cheatsheet and notes for working with virtual environments with conda.
conda create -n my_envconda env listconda env remove -n my_envconda activate my_envsource activate my_envconda deactivate my_envsource deactivate my_envOutside an env, we can use the -n option to specify which environment we want
to install packages into:
conda install -n my_env -c some_channel some_packageIf we are inside the virtual environment, there is no need to use the -n
option. We can install a package with conda install.
Remove pakcage from an env: conda remove -n my_env some_package. If you do
not specify -n, some_package in current env will be removed. If you are not
in any virtual env, some_package in the global Python path will be removed.
When I am inside a virtual env, I am surprised that pip install some_package
installs the package to the global site-package instead of inside the virtual
env.
After some digging, I find that reason is that I was not using the pip command
inside that virtual environment. To check this, use the following command
before using pip install:
which pipIf the pip path is not inside the virtual env, then we are using the
system-wide pip. So pip install some_package will install some_package into
to global Python path instead of the virtual environment.
Conda is the default package and environment management tool shipped with Anaconda.
This post logs my cheatsheet and notes for working with virtual environments with conda.
conda create -n my_envconda env listconda env remove -n my_envconda activate my_envsource activate my_envconda deactivate my_envsource deactivate my_envOutside an env, we can use the -n option to specify which environment we want
to install packages into:
conda install -n my_env -c some_channel some_packageIf we are inside the virtual environment, there is no need to use the -n
option. We can install a package with conda install.
Remove pakcage from an env: conda remove -n my_env some_package. If you do
not specify -n, some_package in current env will be removed. If you are not
in any virtual env, some_package in the global Python path will be removed.
When I am inside a virtual env, I am surprised that pip install some_package
installs the package to the global site-package instead of inside the virtual
env.
After some digging, I find that reason is that I was not using the pip command
inside that virtual environment. To check this, use the following command
before using pip install:
which pipIf the pip path is not inside the virtual env, then we are using the
system-wide pip. So pip install some_package will install some_package into
to global Python path instead of the virtual environment.