You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/python/tutorial-working-with-python-in-visual-studio-step-05-installing-packages.md
+42-22Lines changed: 42 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Python in Visual Studio tutorial step 5, install packages
3
3
titleSuffix: ""
4
4
description: Step 5 of a core walkthrough of Python capabilities in Visual Studio, demonstrating Visual Studio's features for managing packages in a Python environment.
5
-
ms.date: 01/28/2019
5
+
ms.date: 03/09/2020
6
6
ms.topic: tutorial
7
7
author: JoshuaPartlow
8
8
ms.author: joshuapa
@@ -19,31 +19,18 @@ ms.workload:
19
19
20
20
The Python developer community has produced thousands of useful packages that you can incorporate into your own projects. Visual Studio provides a UI to manage packages in your Python environments.
21
21
22
-
1. Select the **View** > **Other Windows** > **Python Environments** menu command. The **Python Environments** window opens as a peer to **Solution Explorer** and shows the different environments available to you. The list includes both environments that you installed using the Visual Studio installer and those you installed separately. The environment in bold is the default environment that's used for new projects.
1. Select the **View** > **Other Windows** > **Python Environments** menu command. The **Python Environments**window opens as a peer to **Solution Explorer** and shows the different environments available to you. The list shows both environments that you installed using the Visual Studio installer and those you installed separately. That includes global, virtual, and conda environments. The environment in bold is the default environment that's used for new projects. For additional information about working with environments, see [How to create and manage Python environments in Visual Studio environments](managing-python-environments-in-visual-studio.md).
25
25
26
-
2. The environment's **Overview** tab provides quick access to an **Interactive** window for that environment along with the environment's installation folder and interpreters. For example, select **Open interactive window** and an **Interactive** window for that specific environment appears in Visual Studio.
27
-
28
-
3. Select the **Packages** tab and you see a list of packages that are currently installed in the environment.
29
-
30
-

31
-
32
-
4. Install `matplotlib` by entering its name into the search field, then select the **pip install**
33
-
34
-

6. After the package is installed, it appears in the **Python Environments** window. The **X** to the right of the package uninstalls it.
39
-
40
-

28
+
> [!NOTE]
29
+
> You can also open the Python Environments window by clicking on the Solution Explorer window and using the Ctrl+K, Ctrl+` keyboard shortcut. If the shortcut doesn't work and you can't find the Python Environments window in the menu, it's possible you haven't installed the Python workload. See [How to install Python support in Visual Studio](installing-python-support-in-visual-studio.md) for guidance about how to install Python.
41
30
42
-
A small progress bar may appear underneath the environment to indicate that Visual Studio is building its IntelliSense database for the newly-installed package. The **IntelliSense** tab also shows more detailed information. Note that until that database is complete, IntelliSense features like auto-completion and syntax checking won't be active in the editor for that package.
43
-
44
-
Note that Visual Studio 2017 version 15.6 and later uses a different and faster method for working with IntelliSense, and displays a message to that effect on the **IntelliSense** tab.
31
+
2. The environment's **Overview** tab provides quick access to an **Interactive** window for that environment along with the environment's installation folder and interpreters. For example, select **Open interactive window** and an **Interactive** window for that specific environment appears in Visual Studio.
45
32
46
-
7. Create a new project with **File** > **New** > **Project**, selecting the **Python Application** template. In the code file that appears, paste the following code, which creates a cosine wave like the previous tutorial steps, only this time plotted graphically:
33
+
3. Now, create a new project with **File** > **New** > **Project**, selecting the **Python Application** template. In the code file that appears, paste the following code, which creates a cosine wave like the previous tutorial steps, only this time plotted graphically. Alternatively, you can use the project you previously created and replace the code.
47
34
48
35
```python
49
36
from math import radians
@@ -58,7 +45,38 @@ The Python developer community has produced thousands of useful packages that yo
58
45
main()
59
46
```
60
47
61
-
8. Run the program with (**F5**) or without the debugger (**Ctrl**+**F5**) to see the output:
48
+
4. With a Python project open, you can also open the Python Environments window from Solution Explorer by right clicking on Python Environments and selecting **View All Python Environments**
5. Looking at the editor window, you'll notice that if you hover over the `numpy` and `matplotlib` import statements that they are not resolved. That's because the packages have not been installed to the default global environment.
## Install packages using the Python Environments window
57
+
58
+
1. From the Python Environments window, click on the default environment for new Python projects and select the **Packages** tab. You will then see a list of packages that are currently installed in the environment.
59
+
60
+

61
+
62
+
2. Install `matplotlib` by entering its name into the search field and then selecting the **Run command: pip install matplotlib** option. This will install `matplotlib`, as well asany packages it depends on (in this case that includes `numpy`).
63
+
64
+

65
+
66
+
5. Consent to elevation if prompted to do so.
67
+
68
+
6. After the package is installed, it appears in the **Python Environments** window. The **X** to the right of the package uninstalls it.
69
+
70
+

71
+
72
+
> [!NOTE]
73
+
> A small progress bar might appear underneath the environment to indicate that Visual Studio is building its IntelliSense database for the newly-installed package. The **IntelliSense** tab also shows more detailed information. Be aware that until that database is complete, IntelliSense features like auto-completion and syntax checking won't be active in the editor for that package.
74
+
>
75
+
> Visual Studio 2017 version 15.6and later uses a different and faster method for working with IntelliSense, and displays a message to that effect on the **IntelliSense** tab.
76
+
77
+
## Run the program
78
+
79
+
1. Now that [matplotlib](https://matplotlib.org/) is installed, run the program with (**F5**) or without the debugger (**Ctrl**+**F5**) to see the output:
62
80
63
81

64
82
@@ -70,3 +88,5 @@ The Python developer community has produced thousands of useful packages that yo
0 commit comments