How to Set Up Visual Studio Code for Python on NVIDIA Jetson

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello it's jim from jetsanax.com today i'm going to share with you how to set up visual studio code for python development microsoft describes visual studio code as a code editor redefined and optimized for building and debugging modern web and cloud applications visual studio code is free and available for your favorite platform linux mac os and windows last month microsoft released an officially supported version of visual studio code which runs on arm and arm 64 machines these are machines like the nvidia jetson developer kits and the raspberry pi first we will install visual studio code with python development support i'll quickly go through how to do a traditional install and then we will do the actual installation centered around adding the ms python extension then we will write an amazingly simple program which will show some of the features that the development environment supports okay here we are on the code.visualstudio.com website i'm on a nvidia jetson nano developer kit let's make this full screen i can do that by double clicking in the title bar installation is well documented on the code.visualstudio.com website but there is a little trick to it which will save you some time there are a couple of download buttons on the webpage which can best be described as honeypots the download buttons will download a linux version of visual studio code which runs on a pc not armed devices instead we need to go down here and click other platforms then select arm 64 to download the correct.deb file it will ask us if we want to keep this file it can harm our computer let's keep it we've been whisked away to the getting started page let's wander down here a little bit and we go to setup install vs code for your platform we follow the platform specific guides below linux let's wander down here a little bit the easiest way to install visual studio code for debian ubuntu based distributions is to download and install the.deb package let's open up a file browser and we'll go to our downloads page here it is let's open up a terminal and now to install it we say sudo apt install like that depending on when you download this the name may be different when we hit carriage return it installs it but i have a better way to do this let's close this up let's double click on the web browser to shrink it on the jetson hacks nano account on github there is a repository named install vs code let's grab this address and clone the repository next let's switch over to that repositories directory there are two installation scripts here the first one install vs code.sh let's take a look at it it simply downloads the latest version of yes code and installs it this is similar to the procedure that we just went through but it's in an automated form let's go back the script that we are going to use is install vs code with python.sh let's take a look at it the script downloads the deb file and then it installs it next we install some python support packages like pip pip stands for pip installs packages and then finally the script installs the python extension into visual studio code let's run this script password installation complete now we're ready to run visual studio code okay let's clear this off let's start up visual studio code let's make it full screen remember at its core visual studio code is an extensible editor by adding different extensions the editor can be turned into a complete development environment for a wide range of languages and code libraries languages include python c c plus plus golang and rust just to name a few visual studio code is a very rich environment if you are unfamiliar with visual studio code this is a good place to get started here's help there's introductory videos tips and tricks a little cheat sheet you can use here's some helpful hints on how to select your tools and languages your settings and key bindings you can make visual studio code act like other editors your favorite editor is probably in that list you can set up the color themes set up folder icons and such and here's some more tutorials to the left of the window is the activity bar it's over here here's the file explorer this is where you deal with your projects the files the project itself folders and things of that nature here's the search and replace area just like any good editor here's where you interact with git it has a built-in source control helper there is also a dedicated debugger area i think this is for people unlike us who actually make mistakes when they program and then down here we have the extensions here are two of the extensions that we installed python we can see the name here mspython.python if we go back and look at our installation file that's how we asked it to install the extension we can look at some of the features here in the feature contributions we can see that there are quite a few of them there are 107 different settings i'm not going to cover all of them in this video certainly worth a look around and then here's 41 different commands you can issue i'm not going to cover those either this is just one extension we can also add other extensions from the marketplace here's some recommended ones docker vim if you want to vim emulation let's look for c plus plus there are a bunch of those there are literally thousands of extensions i'm not going to cover all of them in this video and then we have users and settings let's bring up the settings again there are thousands of settings they're pretty serious take a look at this set real quick let's take a look at our text editor take a look at font let's crank up the editor make this more specific and we'll just change them all to 16. try that and it saves them automatically let's write some code enough of this fiddling around let's open a folder i have this little stub of a program to help us get started okay the first thing you notice is that there is syntax highlighting so let's say we want to print out to the system version here's our first intellisense interaction these are the methods and variables that cis knows about when you're looking at a function that tells you what the arguments are a little bit about it there's also a shortcut to comment lines let's uncomment this line control slash i can do it from the menu here and now we can run our little script here a couple ways to do that we can run the python file in terminal let's do that or we could use this little green button over here it does the same thing so here we have the william list it's pretty simple there are some names which are variations of the name william let's print out the williams here's a suggestion print out the william list that's exactly what i want to do let's run that and there it is let's comment this out [Music] let's say we want to just iterate through this list and print the names out one at a time here's the concept named code snippets we'll click four and this gives us a little bit of a structure so for a william tab over to the next thing and we'll say william list tab again let's print hey william let's try that and see what happens and sure enough they get printed out so let's see what the goal of our simple little program is let's sort the william list and write it to a file to sort the list in python we say william list dot and then we want to sort it this will sort the list in place let's print that out and see what it has to say for itself [Music] save that looks like it sorted it for us okay things are looking good we don't need that anymore let's open up a file and write to it now with open and we want to say the name of the file and we will call this williams.txt and then we add the magic incantation w plus as and we will say file and again a for loop do let's try that out let's see what happens oh williams.txt appeared let's take a look at it not exactly what i wanted here what happened to the line feeds and carriage returns let's fix that file write the name and then we want to add a carriage return at the end let's run that again and see what happens that fixed it so that's pretty simple if you have not seen this construct before what happens is this opens a file the file understands that this is a context at the end of the context the file will close itself this is useful because if you have an exception somewhere in this block it will still close the file for you let's take a quick look at the debugger those are always fun to run and debug create a launch json file this brought up our command palette let's select python file that looks good go back to our testy now we can bring that command palette back up it is context sensitive but if we just hit ctrl shift p right now we get everything and i mean everything just looking at this one thing that is not apparent is that there is a linter running so for example javascript to c you put a semicolon at the end of the line python doesn't like that so it marks it as red if you put in a function it doesn't understand say molly billy the linter works when you save the file it doesn't understand billy it doesn't understand molly so molly's and billy's you're out so let's run the debugger let's put a break point right here let's clear our terminal let's start debugging we'll click right here it takes a little longer to launch the script in debug mode here we are print a william here's our variables the william list a william is now bill here's our debugger controller we can continue step over step into this is good if you are debugging a function of some sort you can restart the program or stop it so let's step over this it goes back to the top of the for loop of course and it printed out bill so single step we can just hop through this this is the unsorted list remember by hitting continue we just go to the next break point or the end of the program whichever comes first i forgot to add we can also choose which python interpreter that we are using we just click down here useful to know it looks like it's up and running this should get us started hey if you like this video give it a thumbs up and if you have not already please subscribe oh and stay safe thanks for watching
Info
Channel: JetsonHacks
Views: 22,797
Rating: undefined out of 5
Keywords: Jetson Nano, Jetson Nano 2GB, Jetson Xavier NX, Jetson AGX Xavier, Jetson TX1, Jetson TX2
Id: 3A5tvO9UbwY
Channel Id: undefined
Length: 17min 2sec (1022 seconds)
Published: Sat Nov 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.