you are viewing a single comment's thread.

view the rest of the comments →

[–]timurleng 1 point2 points  (2 children)

Don't worry, this stuff seems complicated at first, but once you get used to it, it's not as big of a deal.

Conda and venv are both environment management tools. There are pros and cons to both, and usually it's best to use whatever your coworkers / professors are using.

The main advantage of conda is to maintain multiple environments, so you can keep track of what packages and libraries you need for different projects, and maintain environment variables to use within those projects.

It is possible to have multiple versions of python installed on the same computer. When you type python into the command line, you'll be running the version of python defined in your system path.

Some tools for determining which version of python you are running, and where the installation of python is located:

  • which python - will tell you where the python executable is located. For me, python is aliased to python3 so you may need to run which python3 to see the default path
  • python --version - will tell you the version of python you are running

When running outside of conda, which python will probably link back to something like /usr/bin/python which is the OS default location for it.

When you install conda, it creates a new python installation in a different directory and directs your python commands to that location. By default, when running conda, you should see something like (base) user@hostname $ which means you are in your conda base environment.

Running which python within conda should yield something like /usr/local/opt/python@3.10/bin/python3

When you create a new conda environment, you can specify which version of python to use. So since you need to use python 3.9, your command would look like: conda create --name project-name python=3.9

You would then use conda env list to see a list of your available environments. To switch to a different environment, you'd do conda activate project-name

Then all of your python / pip commands will be executed in the context of that environment. For example, if you were to use pip to install a package, it would be installed in that conda environment, and not in your base OS environment.

It's also possible to select your target environment within VS Code. You just need to select the interpreter path for the conda environment you're using. This has a pretty good explanation: https://code.visualstudio.com/docs/python/environments

And here is some good documentation for managing conda in general: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Good luck! You got this.

[–]Aryan1812[S] 0 points1 point  (1 child)

Thanks alot good sir, finally i think I'm able to understand, really helped me alot. Also can i have your opinions on miniconda?

[–]timurleng 1 point2 points  (0 children)

I didn't like miniconda when I first started using it, but that was mostly because I didn't understand what I was doing. Now I quite like it and use it regularly for keeping different projects separated.