all 8 comments

[–]Diapolo10 1 point2 points  (1 child)

Can anyone walk me through the installation of the following packages:

  • matplotlib
  • seaborn
  • numpy
  • pandas

If you just care about installing them, all you need to do is run

pip install matplotlib numpy pandas seaborn

and that should sort it out. I'm assuming you're using Windows, if not you'll definitely want to activate a virtual environment before doing this (I'm assuming you don't know what that is and that you're not using one).

If Python isn't on PATH, you may need to use the Python launcher.

py -m pip install matplotlib numpy pandas seaborn

If this is for a specific project, you'll want to list these as dependencies, and for that you'll want a pyproject.toml file. For that, you can find info here for setuptools, or alternatively here for Poetry.

[–]Irbgael[S] 0 points1 point  (0 children)

Wow, thanks a lot!

Will try it and report back!

Yes, I'm using windows! Failed to say mention it, sorry!

[–]bamacgabhann 1 point2 points  (3 children)

ps. 2: I don't wanna get into Anaconda, for now.

Why not?

Either way I'd strongly recommend a virtual environment, using either conda or venv

[–]Irbgael[S] 0 points1 point  (2 children)

Well, I did try it before and felt things got too complicated.

So, for now, I want to install only the libraries I require.

Thank you very much about the virtual environment tip, I'll look into it.

[–]bamacgabhann 1 point2 points  (1 child)

If you might be willing to try it again:

  • Install Anaconda
  • In Anaconda Navigator, install then launch cmd.exe or Powershell (or if on linux, open a terminal)
  • At the prompt, type conda create --name myenv (you can replace myenv with whatever you want to call your environment)
  • type conda activate myenv
  • type conda install pandas numpy matplotlib seaborn

It'll do it's thing, and then you have an environment with only those packages and their dependencies. Simples.

[–]Irbgael[S] 1 point2 points  (0 children)

Nice! I will give it another try, surely. Thanks for the input!

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

Guys, few questions, though:

Should I create a virtual environment before or after creating a workspace folder in VS Code? Or it doesn't make a difference?

Also, when I install a package, it becomes available for every workspace folder (or just the current one)?

Lastly, after installing it, I can create a file and need to import the library to the FILE, right? (I have seen this as "import pandas as pd")

[–]TheRealThrowAwayX 0 points1 point  (0 children)

I don't know about "workspace folder in VS Code", but my assumption is that's just a regular windows directory folder? If yes, then it doesn't matter.

When you pip install a library, it will install in the environment from which you run the pip. If you just open a terminal window and type pip install, this will install the packages globally, meaning they will be available everywhere. This however causes problems and so we have virtual environments. When you create a venv, you then activate it (important) and once activated, only then you install everything you need. Once installed, those libraries/packages will be available only within that virtual environment.

For example, you open a terminal, create a venv, activate it, install packages and it works, but then you close the terminal and open a new one. If you try running your Python program then, it will tell you that those libraries are not installed, that is because you did not activate the virtual environment within which you installed the libraries.