financial_physician
financial_physician

Reputation: 1978

To understand what Anaconda is a bit better. Anaconda, pip, Jupyter Notebook, PATH

I think I have enough background in computers that at this point I should probably know the distinction between these better than I presently do.

As I understand it, Anaconda is essentially a built out version of pip (built on pip?) that handles packages and dependencies instead of just putting them on your computer. This keeps your system a bit more organized by making it so you don't have mixed environments.

Jupyter Notebook seems to be quite intimately tied to Anaconda but I'm having a hard time understanding how. It doesn't seem like you need to be in an anaconda prompt to issue the command "jupyter notebook" so what exactly is happening here?

I think something that would be very beneficial would be to have an example of a case where I have a package downloaded in conda but if I were to try to make a generic .py file it wouldn't know about the package (I'm not sure if this is true but that seems to be the purpose of having an environment. No?)

I don't think this is as related so I can ask this in a separate post but how does PATH relate to these? I think PATH is somewhat analogous to an import statement but from a very macro perspective. Like if something in PATH than your system knows where it is without asking. Does that make any sense or am I miles off?

I don't know how I've made it this far without understanding how all these things tie together. I feel like I here a lot of buzzwords that have become familiar but I don't know how they all fit together.

Thanks in advance!

Upvotes: 0

Views: 194

Answers (1)

orangeInk
orangeInk

Reputation: 1400

The command line tool conda is a package manager (think apt on Linux) and also manages virtual environments. You can use it to download and install Python packages (amongs other things). So yes, in that sense it's comparable to pip.

Anaconda is a meta-package, i.e. it's simply a list of package names and version numbers, that's currated to make sure all those packages work together. When you install the Anaconda Python distribution you'll get both the command line tool conda as well as all the Python packages that are part of Anaconda.

In order to run a Jupyter server you need certain Python packages. These packages are all part of the Anaconda meta package. So when you have Anaconda installed you already have access to everything you need to start a notebook server. However neither conda nor Anaconda are required for that. The Jupyter packages are just regular Python packages that can be installed in a variety of ways, conda is one of them. So no, Jupyter and Anaconda are not really tied together.

A virtual environment is (to put it simply) an encapsulated Python interpreter. I.e. when you have Python installed on you computer, you can run the python and (usually) the corresponding pip command. pip installs packages that the associated python command can than access. This becomes a problem however when you want to install multiple version of the same package (one project might require a specific version, while another requires a different one). You'd have to manually un- and re-install potentially many packages to make sure all the versions are correct. To avoid this problem (and a few others) you can create a virtual environment, essentially a new copy of Python, which leads to you having multiple Python interpreters installed on your computer. When you want to use one of these Python installations you have to specify which one by activating an environment. This leads to one of your questions: when you install a Python package in one environment, it will only be available there and not in any other environment (unless you installed it there too).

Here's a nice introduction to virtual environments: https://realpython.com/python-virtual-environments-a-primer/

As far as the PATH variable goes: 1. No, you're not far off. Very simply (in this context): activating an environment will change the PATH in order to tell your system which Python interpreter to use. 2. Since it only tangentially relates to the topic at hand I'm not going into more detail here. However it should be easy to search for information on PATH, it even got it's own Wikipedia entry: https://en.wikipedia.org/wiki/PATH_(variable)

Upvotes: 1

Related Questions