Visual Studio Code windows, Python Pandas. No module named pandas. Ask Question Asked 2 years, 7 months ago. Active 2 months ago. Viewed 47k times 8. I set the variables for Env. All necessary modules for Pandas operation are installed by pip. I wanted to run the code to display it in 'Output'. 前提・実現したいことVSCode初心者です。Anacondaで仮想環境をつくって、それを使っています。Excelファイルを操作するためにpandasを使おうとしましたが、xlrdのバージョンを注意されました。(xlrd = 1.0.0) 発生している問題・エラーメッセー.
Working with Python in Visual Studio Code, using the Microsoft Python extension, is simple, fun, and productive. The extension makes VS Code an excellent Python editor, and works on any operating system with a variety of Python interpreters. It leverages all of VS Code's power to provide auto complete and IntelliSense, linting, debugging, and unit testing, along with the ability to easily switch between Python environments, including virtual and conda environments.
This article provides only an overview of the different capabilities of the Python extension for VS Code. For a walkthrough of editing, running, and debugging code, use the button below.
Install Python and the Python extension
The tutorial guides you through installing Python and using the extension. You must install a Python interpreter yourself separately from the extension. For a quick install, use Python 3.7 from python.org and install the extension from the VS Code Marketplace.
Once you have a version of Python installed, activate it using the Python: Select Interpreter command. If VS Code doesn't automatically locate the interpreter you're looking for, refer to Environments - Manually specify an interpreter.
You can configure the Python extension through settings. Learn more in the Python Settings reference.
Windows Subsystem for Linux: If you are on Windows, WSL is a great way to do Python development. You can run Linux distributions on Windows and Python is often already installed. When coupled with the Remote - WSL extension, you get full VS Code editing and debugging support while running in the context of WSL. To learn more, go to Developing in WSL or try the Working in WSL tutorial.

Insiders program
The Insiders program allows you to try out and automatically install new versions of the Python extension prior to release, including new features and fixes.
If you'd like to opt into the program, you can either open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and select Python: Switch to Insiders Daily/Weekly Channel or else you can open settings (⌘, (Windows, Linux Ctrl+,)) and look for Python: Insiders Channel to set the channel to 'daily' or 'weekly'.
Run Python code
To experience Python, create a file (using the File Explorer) named hello.py
and paste in the following code (assuming Python 3):
The Python extension then provides shortcuts to run Python code in the currently selected interpreter (Python: Select Interpreter in the Command Palette):
- In the text editor: right-click anywhere in the editor and select Run Python File in Terminal. If invoked on a selection, only that selection is run.
- In Explorer: right-click a Python file and select Run Python File in Terminal.
You can also use the Terminal: Create New Integrated Terminal command to create a terminal in which VS Code automatically activates the currently selected interpreter. See Environments below. The Python: Start REPL activates a terminal with the currently selected interpreter and then runs the Python REPL.
For a more specific walkthrough on running code, see the tutorial.
Autocomplete and IntelliSense
The Python extension supports code completion and IntelliSense using the currently selected interpreter. IntelliSense is a general term for a number of features, including intelligent code completion (in-context method and variable suggestions) across all your files and for built-in and third-party modules.
IntelliSense quickly shows methods, class members, and documentation as you type, and you can trigger completions at any time with ⌃Space (Windows, Linux Ctrl+Space). You can also hover over identifiers for more information about them.
Tip: Check out the IntelliCode extension for VS Code (preview). IntelliCode provides a set of AI-assisted capabilities for IntelliSense in Python, such as inferring the most relevant auto-completions based on the current code context.
Linting
Linting analyzes your Python code for potential errors, making it easy to navigate to and correct different problems.
The Python extension can apply a number of different linters including Pylint, pycodestyle, Flake8, mypy, pydocstyle, prospector, and pylama. See Linting.
Debugging
No more print
statement debugging! Set breakpoints, inspect data, and use the debug console as you run your program step by step. Debug a number of different types of Python applications, including multi-threaded, web, and remote applications.
For Python-specific details, including setting up your launch.json
configuration and remote debugging, see Debugging. General VS Code debugging information is found in the debugging document. The Django and Flask tutorials also demonstrate debugging in the context of those web apps, including debugging Django page templates.
Environments
The Python extension automatically detects Python interpreters that are installed in standard locations. It also detects conda environments as well as virtual environments in the workspace folder. See Configuring Python environments. You can also use the python.pythonPath
setting to point to an interpreter anywhere on your computer.
The current environment is shown on the left side of the VS Code Status Bar:
The Status Bar also indicates if no interpreter is selected:

The selected environment is used for IntelliSense, auto-completions, linting, formatting, and any other language-related feature other than debugging. It is also activated when you use run Python in a terminal.
To change the current interpreter, which includes switching to conda or virtual environments, select the interpreter name on the Status Bar or use the Python: Select Interpreter command.
VS Code prompts you with a list of detected environments as well as any you've added manually to your user settings (see Configuring Python environments).
Installing packages
Packages are installed using the Terminal panel and commands like pip install <package_name>
(Windows) and pip3 install <package_name>
(macOS/Linux). VS Code installs that package into your project along with its dependencies. Examples are given in the Python tutorial as well as the Django and Flask tutorials.
Jupyter notebooks
If you open a Jupyter notebook file (.ipynb
) in VS Code, you can use the Jupyter Notebook Editor to directly view, modify, and run code cells.
You can also convert and open the notebook as a Python code file. The notebook's cells are delimited in the Python file with #%%
comments, and the Python extension shows Run Cell or Run All Cells CodeLens. Selecting either CodeLens starts the Jupyter server and runs the cell(s) in the Python interactive window:
Opening a notebook as a Python file allows you to use all of VS Code's debugging capabilities. You can then save the notebook file and open it again as a notebook in the Notebook Editor, Jupyter, or even upload it to a service like Azure Notebooks.
Using either method, Notebook Editor or a Python file, you can also connect to a remote Jupyter server for running the code. For more information, see Jupyter support.
Testing
The Python extension supports testing with the unittest, pytest, and nose test frameworks.
To run tests, you enable one of the frameworks in settings. Each framework also has specific settings, such as arguments that identify paths and patterns for test discovery.
Once discovered, VS Code provides a variety of commands (on the Status Bar, the Command Palette, and elsewhere) to run and debug tests, including the ability to run individual test files and individual methods.
Configuration
The Python extension provides a wide variety of settings for its various features. These are described on their relevant topics, such as Editing code, Linting, Debugging, and Testing. The complete list is found in the Settings reference.
Other popular Python extensions
The Microsoft Python extension provides all of the features described previously in this article. Additional Python language support can be added to VS Code by installing other popular Python extensions.
- Open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)).
- Filter the extension list by typing 'python'.
The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.
Next steps
- Python Hello World tutorial - Get started with Python in VS Code.
- Editing Python - Learn about auto-completion, formatting, and refactoring for Python.
- Basic Editing - Learn about the powerful VS Code editor.
- Code Navigation - Move quickly through your source code.
01 Oct 2020
Table of Contents
- Installing Windows-Store Python & running a Python program
- Install Python from the Windows store
- IDEs
- Using our IDE to program
- Modules
- Installing a “module”
- Updating Python itself
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, 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”
Did you get Python up and running?
Yay! I’m thrilled I could help.
If you’d like, I’d love a Ko-Fi. (Chai for me!) 🥰
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.
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).
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.
The button will be replaced by a meter indicating your download and installation progress.
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.
Some tech details for nerds
Skip this little list if it doesn’t make any sense to you
- 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 usingwhere python
in the command line tells me one thing but various informational messages in VSCode tell me another:C:UsersYOUR_USERNAMEAppDataLocalMicrosoftWindowsApps
C:UsersYOUR_USERNAMEAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.#.#_LONGWEIRDTEXT
- 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
. - 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 withpython
such aspython --version
, or one beginning withpip
such aspip --version
, they run properly.
Hello World: running a Python program
Open up a nice text editor like Notepad++.
Create a new file. In it, type the following text, using the apostrophe key on your keyboard for the single quotes:
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 (.).”
Once you’ve done that, open a “command-line prompt” by hitting the Windows key on your keyboard, typing “cmd
,” and hitting “enter.”
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:
You should see “Hello World
” right below your command.Go you! You just wrote a program in Python and executed it!
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 or CodeBunk, 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.
Install VSCode
Installing VSCode is a straightforward process of downloading the software from Microsoft’s web site 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.
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.
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.
Just for fun, click “Python #.#.# 64-bit
” in the bottom-left corner of VSCode.
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.
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:examplehello.py
.
(Note: I closed out of the tip that popped up telling me I hadn’t yet installed a “linter.”)
You should see that hello.py
contains the following code:
To run this code, click the green right-facing triangle (the “play button” / “run button”) toward the top right corner of VSCode.
In the “Terminal” tab of a panel below your code, you should see the words:
It should appear between “command prompts” that say:
Now erase the entire contents of the file, and on line 1, type:
Then click the big green “run” button.
In the “Terminal” output below, do you see the following output text?
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:
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:
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:UsersYOUR_USERNAME>
”) in the Terminal pane below.
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” 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:
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:UsersYOUR_USERNAME>
”) at the bottom of your the Terminal pane in VSCode.
Run your code again, which, as a reminder, looks like this:
Now you should get the boring “nothing happens except the command prompt incrementing” thing.
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:
Installing another module
The same process works for other Python modules, like 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:

To install Simple Salesforce on your computer, just run this command in the VSCode Terminal command prompt:
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:
Updating Python itself
Unresolved Import Pandas Visual Studio Code
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” 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.
- In your VSCode Terminal panel, type the command
pip freeze > c:exampleinstalled-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.
- 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
.” - The Windows start menu should filter your list of available programs to suggest the Add or remove programs system configuration area. Click it.
- In the “Search this list” box, type “
python
,” click your version of Python that you no longer want, and click the Uninstall button. - 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 thatpython
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
inC:UsersYOUR_USERNAMEAppDataLocalMicrosoftWindowsApps
, 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 executingpython
just kind of … does nothing.
- Nerd reason: The uninstall left behind
- Once the Windows Store finishes installing your new version of Python, close out any
.py
files you have open in VSCode. - Re-open a
.py
file such ashello.py
that we wrote earlier. VSCode should automatically find your new Python interpreter and put your latest version number into the bottom-left corner. - 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.
- To restore your old module installations, run the following code in the VSCode Terminal:
pip install -r c:exampleinstalled-modules.txt
(alter the file path if you saved it somewhere else) - Run a Python file containing
import
statements in the code to verify that your expected modules are now in place, as done above withimport pandas
andimport numpy
andimport 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:
Updating all modules at once
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:
Happy Programming

You now have a working environment for editing CSV files in Python!
- 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.
- You know how to install & update “modules” that you hear might be useful.
(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 likepandas
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.
You should see the following output in your console at right:
Pandas For Visual Studio Code
Now you’ve opened a CSV spreadsheet file with Python – you’re off to the races! Head here to learn new skills and put them in action on your computer.
