This short post shows you how to install the Python package in Visual Studio Code, which is widely used in the programming environment. The prerequisite for our operation is the Python extension in Visual Studio code, which should be installed at the very beginning (Pic. 1).
You can do the installation from this link and get the newest version of the Python language.
Next, you can start programming with Python in Visual Studio Code without a problem. However, it seems, like you are somewhat restricted when you discover, that there are problems with installing the external Python libraries and importing them to Visual Studio Code. I hope, that this quick solution will help you manage these issues.
The biggest problem at the initial stage is the presumed lack of the Pip installation in our Visual Studio Code software. The Pip is the most popular tool for installing Python packages and includes a modern version of Python. It provides the essential core features for finding, downloading, and installing Python packages.
In Visual Studio Code, the Pip seems to be not recognized as an internal or external command (Pic. 2). Usually, we choose the quickest way of Python module installation, where after visiting the module we want to get, we simply make the copy of the top installation command and next, paste it to our Python dedicated software, i.e. PyCharm.
In the Visual Studio Code, we need to change our pip command a bit. The proper command in our terminal should be:
C:\Users\m\Desktop\Python> py -m pip
Once we hit enter, the whole list of commands should be populated as you can see below (Pic. 3).
Now we are sure, that the Pip has been recognized by our Visual Studio Code. It means, that the Python library can be installed, which is great.
In order to make the installation correctly, we can’t simply make a copy of the main command available just below the library name (Pic. 2).
If we would do so, then our command would look like this:
C:\Users\m\Desktop\Python> py -m pip pip install numpy
and we would have to remove one “pip” preventing at least one space between the strings as you can see here.
I think, much easier is just type the py-m in our terminal path:
C:\Users\m\Desktop\Python> py -m
and then append the library command, which we want to install (Pic. 2)…
C:\Users\m\Desktop\Python> py -m pip install numpy
After hitting the “Enter” button, you can see the installation progress. Next, the tool will inform you the information about the target path where the library has been installed as well as the new pip version if available (Pic. 4).
In order to make sure, that everything is alright, you can import the library to the file you are working on, by simply typing:
If something would be wrong, the Python console will underline your code with a wavy red line. Since everything has been installed properly, the library is to be recognized instantly by the Visual Studio Code (Pic. 5).
I highly recommend using Visual Studio Code, which appears to be the best coding application in the market. The biggest advantage is a broad opportunity for coding in various programming languages. This application is great and supersedes other programming applications dedicated to a specified language. As a result, a lot of memory is saved keeping our computers faster.
- Python extension for Visual Studio Code