2
$\begingroup$

I am absolutely confused due to the number of different ways and the abundance of articles explaining how to create a virtual environment in Anaconda. You could use conda or virtualenvironment to create one. Also depending on how you create it, you need to use either conda or pip to install additional libraries. I tried to read but it only confused me more!

Up until now I haven't created one and install additional packages using pip into the base folder. (I am using Anaconda and Spyder). Can someone please help me with the best practice to create a virtual environment and how to install additional libraries? I use Spyder as my primary IDE.

PS: if you think this is a duplicate question, kindly post a link to the question rather than downvoting, and I'll close or delete this question myself.

$\endgroup$
2
  • $\begingroup$ Just for the joke. Do not use Anaconda :D. It is bloated. You can do almost anything with a standard python installation. $\endgroup$ Nov 7, 2021 at 20:02
  • $\begingroup$ I know it now but it's too late:P $\endgroup$
    – spectre
    Nov 8, 2021 at 11:47

2 Answers 2

2
$\begingroup$

Whenever working in a collaborative environment it's always best to create env using environment.yml.

  • Easily set up additional channels(if required)for downloading relevant packages.
  • Can add all the dependencies which can be downloaded through these channels and also pip dependencies in same file.

Though it takes additional work at start but it helps in debugging later :)

Resources:

  1. Create an environment file
  2. Creating an environment from an environment.yml file
$\endgroup$
3
$\begingroup$

Use conda to create a new environment and only install packages using conda install. Dont run pip and conda install in same virtual env it will eventually mess up the conflicting packages and further installs will never finish installing new packages with conda.

Conda analyzes each package for compatible dependencies, and how to install them without conflict. If there is a conflict, Conda will let you know that the installation cannot be completed. By comparison, Pip installs all package dependencies regardless of whether they conflict with other packages already installed and eventually your environment gets corrupted by Pip install.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.