I am going through the painful process of learning how to manage packages/ different (virtual) environments in Python/Anaconda. I was told that Anaconda is basically a python installation with all the packages I need (e.g. numpy, scipy, sci-kit learn etc).
However, when I create a new environment, none of these packages is readily available. I cannot import them when using PyCharm with the newly created environment. When I check the Pycharm project interpreter, or the anaconda navigator environments tab, It seems that indeed none of these packages are installed in my new environments. Why is this? It doesn't make sense to me to provide all these packages, but then not make them ready for use when creating new environments. Do I have to install all these packages manually in new env's or am I missing something?
Kindest regards, and thanks in advance.
If a package isn't available from Anaconda Repository or Anaconda Cloud, you can try installing it with pip , which conda installs by default in any environment created with Python.
If you don't have Python yet and want the simplest way to get started, we recommend you use the Anaconda Distribution - it includes Python, NumPy, and many other commonly used packages for scientific computing and data science.
Adding default packages to new environments automatically Open Anaconda Prompt or terminal and run: conda config --add create_default_packages PACKAGENAME1 PACKAGENAME2. Now, you can create new environments and the default packages will be installed in all of them.
While Conda-Forge has many packages, it doesn't have all of them; many Python packages can only be found on PyPI. You can deal with lack of these packages in a number of ways.
The reason the default python
environment doesn't come with numpy
is because maybe you don't want numpy
in the environment. Imagine writing an API (or general software package) where your users may or may not have access to numpy
. You might want to run tests to make sure your software fails gracefully or has a pure python fallback if numpy
is not installed on your user's machine. Conda environments provide this (insanely useful) benefit. Of course, the package in question doesn't have to be numpy
. There are some more esoteric packages where this type of testing is useful.
Furthermore, you can create a conda environment with numpy
pre-installed, or any other package you want pre-installed (just add them to the end of the conda create
command):
conda create --name my-env-name numpy
Anaconda comes with available packages such as numpy, scipy, and sci-kit learn, but if you want to use them within your environment, you must:
1) Create the environment:
conda create --name new_env
2) Activate the environment:
source activate new_env
3) Install the desired package using conda install
conda install numpy
If you'd like to create a new environment that includes installations of all available Anaconda packages, see create anaconda python environment with all packages. You can include anaconda
in the list of packages to install in the environment, which is a 'meta-package' meaning 'all the packages that come with the Anaconda installation'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With