Issue
I've been struggling with Anaconda virtual environments and Spyder. I want to know if there's is a way to configure Anaconda so that whenever I create a new virtual environment, the spyder-kernel module is automatically installed in it. That would make easier to switch between virtual environments while using Spyder. I love Spyder but I'm thinking of moving to VSCode or PyCharm because of this.
I googled my question and found no useful answers.
Solution
Yes, this is possible and documented here.
In a conda
prompt enter:
conda config --add create_default_packages package_name_1 package_name_2
When later creating new environments, for example:
conda create -n new_env
the packages package_name_1
and package_name_2
will be automatically installed.
Note that this will also install all the dependencies of these packages, including python. If you want to have a specific version of one of these dependencies, just specify that when you create the environment.
Below is an example how to do automatically install spyder-kernels
when creating new environments, and with the optional setting to specifying a python version and using conda-forge
channel when creating a new environment.
First add spyder-kernels
to the default package config (this is a one time config command, all environments created after this will install spyder-kernels
) :
conda config --add create_default_packages spyder-kernels
Later, I create my environment (here I don't have to ask to install spyder-kernels
):
conda create -n new_env -c conda-forge python=3.9 -y
With the (partial) output:
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: path_to_environments\envs\new_env
added / updated specs:
- python=3.9
- spyder-kernels
...
Answered By - rhkarls
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.