Setting up Windows Store Python with Pandas in VSCode
Tags: python, tutorial, vscode, windows
Published: 2020-10-01 17:16:50

---
title: Setting up Windows Store Python with Pandas in VSCode
published: true
date: 2020-10-01 15:00:00 UTC
description:  "A great solution when you don't have admin rights"
cover_image: https://katiekodes.com/images/header-win-store-python-vscode-en.png
tags: python, tutorial, vscode, windows
canonical_url: https://katiekodes.com/python-windows-store-pandas-vscode/
---

My beloved Spyder IDE suddenly stopped working on me, and I needed to install Python + Pandas on a new computer anyway, so I decided to explore installing Python _(and various packages I use with it such as Pandas)_ out of the Windows Store, executing code in VSCode as an IDE.

The Windows installation of Python is pretty stripped down, [like that of Miniconda](https://katiekodes.com/setup-python-windows-miniconda/), and similarly doesn't require admin rights to one's computer.

Therefore, I'll cover hand-installing a few simple packages as in my older tutorial.

_Note:  This tutorial is aimed at non-programmers who just want to edit a few CSV files with Python.  If you're a serious data scientist, learn the nuts and bolts of Anaconda at [Real Python's "Setting Up Python for Machine Learning on Windows"](https://realpython.com/python-windows-machine-learning-setup/)_

## Installing Windows-Store Python & running a Python program

### Install Python from the Windows store

Click the Windows icon in the bottom-left corner of your screen, and then without clicking anything else, type the word "`store`."

The Windows **start menu** should filter your list of available programs to suggest the **Microsoft Store** app.  Click it.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/01-start-menu-store.png)

In the upper right corner of the **store** window, click the text entry panel next to a magnifying glass and type the word "`python`" and press **enter**.

Available software to download should filter itself.  Click the piece of Software named "**Python #.#**" but not "**Python #.# (RC)**" where "#.#" is some number.  I suggest choosing the greatest non-RC number available to you _(3.8 at the time of writing this tutorial, although as you can see in the screenshot, 3.7 is also available to me)_.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/02-store-search.png)

Verify the legitimacy of the software by checking that the **Python Software Foundation** is the publisher of the software, then click the big blue "**Get**" button.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/03-store-get.png)

The button will be replaced by a meter indicating your download and installation progress.
![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/04-store-downloading.png)

When finished, you can close the Store app.

Click the Windows icon in the bottom-left corner of your screen -- at the top of your **start menu**, you should see "**Python #.#**" and "**IDLE (Python #.#)**" software added.  _(Alternatively, they should be under "**P**" and "**I**," respectively, in your start menu's main list of programs.)_

If you'd like, you can click one of them and try running `print('Hello')` right from the Python command prompt windows they bring up, but personally, I don't like interactive Python command lines.  I usually need to write multiple-command script files and execute them.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/05-start-menu-new.png)

#### Some tech details for nerds

Skip this little list if it doesn't make any sense to you

1. The Windows Store seems to install copies of the Python interpreter _(a.k.a. the program `python.exe`)_, which makes your computer understand code written in the Python programming language at both these two places -- I'm not 100% sure which it's really using, since using `where python` in the command line tells me one thing but various informational messages in VSCode tell me another:
	* `C:\Users\YOUR_USERNAME\AppData\Local\Microsoft\WindowsApps\`
	* `C:\Users\YOUR_USERNAME\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.#.#_LONGWEIRDTEXT\`
2. The Windows Store seems to install PIP, which helps you install and upgrade Python "modules" _(extensions to the programming language)_ , into the same 2 folders as `pip.exe`.
3. The Windows Store installer seems to do a pretty good job of putting these two executables in your operating system's `PATH` environment variable, so that when you simply open a Windows command line and type a command beginning with `python` such as `python --version`, or one beginning with `pip` such as `pip --version`, they run properly.

### Hello World:  running a Python program

Open up a nice text editor like [Notepad++](https://notepad-plus-plus.org/).

Create a new file.  In it, type the following text, using the apostrophe key on your keyboard for the single quotes:

```python
print('Hello World')
```

Do "**File -> Save As**."

Pick a nice folder for your program _(personally, I'm going to save mine under `C:\example\`, but you might want to put it on your desktop)_ and save it there with a filename of "**`hello.py`**," being sure to change the "**Save as type**" option to "Python file" or to "All Types (*.*)."

![Screenshot](https://katiekodes.com/images/screenshot-miniconda-09-firstprogram.png)

Once you've done that, open a "command-line prompt" by hitting the Windows key on your keyboard, typing "`cmd`," and hitting "enter."

![Screenshot](https://katiekodes.com/images/screenshot-miniconda-10-cmdblank.png)

At the prompt, type something along the following lines, only changing the file paths to be where _**your**_ "**`python.exe`**" lives and where _**your**_ "**`hello.py`**" lives, and hit your **enter** key:

```
python c:\example\hello.py
```

You should see "`Hello World`" right below your command.Go you!  You just wrote a program in Python and executed it!

![Screenshot](https://katiekodes.com/images/screenshot-miniconda-14-anacmdsuccess.png)

---

## IDEs

### Setting up an IDE for pleasant programming

That wasn't a particularly fun way to code, was it?

If you've practiced coding in an online "IDE" like [Repl.it](https://repl.it) or [CodeBunk](https://codebunk.com), you know that coding can be as easy as clicking a big "run" button every time you type enough text that you wonder what it does.

To get the same experience, we need to install an "IDE" on our PC.

A popular one is Microsoft's [VSCode](https://code.visualstudio.com/).

### Install VSCode

Installing VSCode is a straightforward process of [downloading the software from Microsoft's web site](https://code.visualstudio.com/) and double-clicking the installer file, then following directions as prompted.

I don't have screenshots because it was already installed on my computer.  I have admin rights to the computer I was working on, so please let me know in the comments if this tutorial doesn't work for you in a pure no-admin-rights context -- I suspect I installed VSCode for the whole computer when I installed it.

[Microsoft has some tips on installing VSCode for a local user, without admin rights, here.](https://code.visualstudio.com/docs/setup/windows)

Once you've installed VSCode, run it.

### Python-ifying VSCode with a plugin

At the far left of VSCode, click the bottom icon that looks like a square joining 3 other squares to make a bigger square.  This will bring you to the **Extensions** section of VSCode.

In the search box at the top of the left-hand control for Extensions, type "`python`" and click the official **Python** plugin published by **Microsoft** itself.

Click the green **Install** button.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/31-vscode-plugin.png)

When your extension finishes installing, it might let you know that there's a way to change _which_ Python interpreter VSCode uses to facilitate executing code written in the Python programming language.

Go ahead and click "Got it!" if so.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/32-vscode-env.png)

Just for fun, click "`Python #.#.# 64-bit`" in the bottom-left corner of VSCode.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/33-vscode-env.png)

VSCode's command pallet will open toward the top center of VSCode and give you an option to choose which `python.exe` installation on your computer you'd like it to treat at _**the**_ Python interpreter on your computer.

_(Programmers sometimes keep multiple versions of Python installed on their computer all at once.)_

Click anywhere outside this command pallet menu to get rid of it.  I just wanted to show you around in case you were curious.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/34-vscode-env.png)

### Using our IDE to program

Close VSCode and fire it up again.  You might not see `Python #.#.# 64-bit` in the bottom-left corner of VSCode anymore.

That's okay -- you can bring it back by navigating through the top menu to **File** > **Open File** and opening the file you saved at, for example, `c:\example\hello.py`.

_(Note:  I closed out of the tip that popped up telling me I hadn't yet installed a "linter.")_

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/35-save-dot-py.png)

You should see that `hello.py` contains the following code:

```python
print('Hello World')
```

To run this code, click the green right-facing triangle _(the "play button" / "run button")_ toward the top right corner of VSCode.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/36-run-hello.png)

In the "**Terminal**" tab of a panel below your code, you should see the words:

```
Hello World
```

It should appear between "command prompts" that say:

```
PS C:\Users\YOUR_USERNAME>
```

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/37-hello-results.png)

Now erase the entire contents of the file, and on line 1, type:

```python
print('Hello again')
```

Then click the big green "run" button.

In the "Terminal" output below, do you see the following output text?

```
Hello again
```

Congratulations -- you've set up VSCode and you're almost ready to write bigger programs!

In the top menu, click "**File**" -> "**Save**" because why not be proud of this working code?  It's good to get used to saving your work as soon as you like it.

#### Some tech details for nerds

> VSCode should have filled in the command prompt before "Hello World" with something along the lines of `& python c:/example/hello.py`.
> 
> The command prompt after "Hello World" should be available for you to type commands into.
> 
> Try typing "`python --version`" and hitting **enter** to confirm that you have a working command prompt to your computer through this panel of VSCode.)
> 
> You'll be using the Terminal's command prompt when you need to update extensions to Python, so you might as well try your first command in it.

---

## Modules

### Checking whether "modules" are installed

Now you need to learn what it looks like when a given extension to the Python language, also known as a "library" or "package" or, particularly in Python, a "module," is installed.

Backspace out the entirety of your code and on line 1, type:

```python
import pandas
```

Click the "run" button.

If you get a dump of text in your console, saying the following, you now know that you don't have the module called "`pandas`" installed:

```
Traceback (most recent call last):
  File "C:/example/hello.py", line 1, in <module>
    import pandas
ModuleNotFoundError: No module named 'pandas'
```

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/38-run-pandas-error.png)

If you **do** have "pandas" installed, nothing special happens.

If you have "pandas" installed, when you run this code, you just get a new command prompt ("`PS C:\Users\YOUR_USERNAME>`") in the Terminal pane below.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/41-run-pandas-blank.png)

Let's fix things and install Pandas so our code runs.

### Installing a "module"

When using the Windows Store installation of Python, you'll use the "[pip installer](https://www.w3schools.com/python/python_pip.asp)" to install extended Python commands _("modules")_ onto your computer so that you can run Python code written with these extended commands.

PIP is just a command-line program that works in the command prompts of the **Terminal** pane of VSCode.  It goes out and downloads things from the internet and installs them on your computer for you.

In the command prompt in your **Terminal** pane in VSCode, type the following and hit "enter" to execute:

```shell
pip install pandas
```

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/39-pip-install-pandas.png)

You may notice that PIP downloaded a lot more than just "pandas."  There's another package that's highly intertwined with "pandas" called "numpy" that it's going to download for us ... we'll check after we're all done that it installed, too.

The download and install takes a few minutes.

The installation process is completete when you see a new command prompt ("`PS C:\Users\YOUR_USERNAME>`") at the bottom of your the Terminal pane in VSCode.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/40-pip-install-pandas.png)

Run your code again, which, as a reminder, looks like this:

```python
import pandas
```

Now you should get the boring "nothing happens except the command prompt incrementing" thing.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/41-run-pandas-blank.png)

> Note:  If you'd like to see that the "numpy" module also installed, add a 2nd line of code to your program at left and click "Run" again, with the full code being:
> 
> ```python
> import pandas
> import numpy
> ```

</div>

#### Installing another module

The same process works for other Python modules, like [Simple Salesforce](https://github.com/simple-salesforce/simple-salesforce), which makes it easier to download and update data in a Salesforce database.

Running the following code will produce an error if Simple Salesforce is not installed, but will do nothing if it is installed:

```python
import simple_salesforce
```

To install Simple Salesforce on your computer, just run this command in the VSCode Terminal command prompt:

```shell
pip install simple-salesforce
```

> Note:  in **pip** commands, this module is "simple-salesforce" with a hyphen.  When doing an "import" in Python code, it's an underscore.  Not sure why ... that's just how the author packaged it up.

### Updating a "module"

Has it been a year, and you've heard there are newer & greater versions of Pandas?

At your prompt in the VSCode **Terminal**, run the following command:

```shell
pip install pandas --upgrade
```

### Updating Python itself

If you have, say, version 3.8.0 and you want to bring your system up to the latest version offered in the Microsoft Store _(for me today, that's 3.8.6)_, you might be able to do so as described in "[How to manually update apps and games from the Microsoft Store](https://www.digitalcitizen.life/how-manual-search-app-updates-windows-store)" by Ciprian Adrian Rusen for Digital Citizen.

If, on the other hand, you chose version 3.7 of Python and want to switch to version 3.8, I think the easiest way to ensure you keep your installation simple would be to simply uninstall Python the way you'd install any program from Windows, then reinstall it.

The only catch is that this will likely uninstall all the modules you've installed with **pip**.  Maybe you want a clean start, but for this tutorial, we'll take a backup of the list of those modules before we begin and reinstall them when done.

1. In your VSCode **Terminal** panel, type the command `pip freeze > c:\example\installed-modules.txt` _(changing the path of the filename to the right of `>` if you like)_ and press **Enter** to execute it.
	* Check out the file you just created -- it should list out the Python modules installed on your computer.
2. Click the Windows icon in the bottom-left corner of your screen, and then without clicking anything else, type the words "`add or remove programs`."
3. The Windows **start menu** should filter your list of available programs to suggest the **Add or remove programs** system configuration area.  Click it.
4. In the "Search this list" box, type "`python`," click your version of Python that you no longer want, and click the **Uninstall** button.
5. You're now in a bit of a weird nowhere-land, where executing a VSCode Terminal command of `python --version` neither gives you a version number nor denies that `python` is a legitimate Windows command.  If you have a `.py` file open in VSCode, the bottom right corner also probably gives you a yellow warning message of "Select Python interpreter."  Hopefully we can move past that in a moment.
	* Nerd reason:  The uninstall left behind `python.exe` in `C:\Users\YOUR_USERNAME\AppData\Local\Microsoft\WindowsApps\`, so it's still a valid Windows program.
	* However, that program's job seems to be to simply call the `python.exe` from a sub-folder _(e.g. `PythonSoftwareFoundation.Python.#.#_LONGWEIRDTEXT`)_ with an actual versioned installation of Python in it, so executing `python` just kind of ... does nothing.
6. Once the Windows Store finishes installing your new version of Python, close out any `.py` files you have open in VSCode.
7. Re-open a `.py` file such as `hello.py` that we wrote earlier.  VSCode should automatically find your new Python interpreter and put your latest version number into the bottom-left corner.
8. Run your Python file to make sure it works.
	* Tip:  Choose a Python file that doesn't do anything dangerous.  Don't, for example, choose a Python file you once wrote whose job is to delete a bunch of files.  Use a simple Hello World script.
9. To restore your old module installations, run the following code in the VSCode **Terminal**:  `pip install -r c:\example\installed-modules.txt` _(alter the file path if you saved it somewhere else)_
10. Run a Python file containing `import` statements in the code to verify that your expected modules are now in place, as done above with `import pandas` and `import numpy` and `import simple_salesforce`.

After updating Python, you might also want to update all of your modules at once to their latest versions.

You can do so with the following command suggested in [this blog post by ActiveState](https://www.activestate.com/resources/quick-reads/how-to-update-all-python-packages/):

#### Updating all modules at once

```shell
pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
```

#### Updating PIP

Funnily, **pip** itself doesn't get upgraded when you "update everything," so if you're seeing nastygrams that it's out-of-date, you can also run:

```shell
pip install pip --upgrade
```

---

## Happy Programming

You now have a working environment for editing CSV files in Python!

1. You have an "IDE," or as I like to think of it, a "text editor with a run button," called **VSCode**, that runs code you type into it as you see fit.
2. You know how to install & update "modules" that you hear might be useful.<br/>_(Be careful and don't trust any old module you find on the internet.  It's nothing more than "custom code that you're running on your computer.  Make sure it's not from someone sketchy.  Big names like `pandas` are fine, though.)_

## Door Prize

Here's a "door prize script" to get you started:  try copying & pasting it into `hello.py` in VSCode and running it.

```python
import pandas
pandas.set_option('expand_frame_repr', False)
filepath = 'https://raw.githubusercontent.com/pypancsv/pypancsv/master/docs/_data/sample1.csv'
df = pandas.read_csv(filepath)
print(df)
```

You should see the following output in your console at right:

```
      Id    First      Last           Email                      Company
0   5829    Jimmy    Buffet  jb@example.com                          RCA
1   2894  Shirley  Chisholm  sc@example.com       United States Congress
2    294  Marilyn    Monroe  mm@example.com                          Fox
3  30829    Cesar    Chavez  cc@example.com          United Farm Workers
4    827  Vandana     Shiva  vs@example.com                     Navdanya
5   9284   Andrea     Smith  as@example.com     University of California
6    724   Albert    Howard  ah@example.com  Imperial College of Science
```

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-python-pandas-windows-2020-09/42-run-pandas-data.png)

Now you've opened a CSV spreadsheet file with Python -- you're off to the races!  Head [here](https://pypancsv.github.io/pypancsv/quickexamples/) to learn new skills and put them in action on your computer.