The most convenient way to run your Python code is to have a button you can click and watch your code run inside of the IDE. This method is exceedingly reliable, but it can be a little inconvenient. Output from your script will appear in the external terminal, and you’ll just VSC as a glorified text editor. Open the terminal type python path/to/script.py, hit enter, and your code will run. It’s just what I’m used to, and there’s more room in the code editor to navigate the code without the terminal window pulled up.Īll you need to do this is have a terminal where the python distribution you want to use is set up as the default (so when you start an interactive Python session by typing python you get the version and distribution you expect). To this day I usually open an external command prompt if I’m running a conda-based Python distribution. Nevertheless, it’s simple and the easiest way to get started if you don’t want to spend time figuring out settings inside of Code. Unfortunately, this can also be somewhat inconvenient because you have to open the proper terminal, activate a python environment, then type a command in the terminal whenever you want to run a script. If you want a method to run code in VSC that is guaranteed to work it’s using VSC to write and edit your scripts and then running the scripts from an external command prompt. If one of these methods doesn’t work or seems too complicated, don’t worry there are three others you can try! 1. Over the last few years, I’ve identified 4 reliable methods to run Python code in VSC. If you’re having the same problem, this article is for you. This was a major sticking point because I often use various Python distributions (both Anaconda/Miniconda distributions and default Python distributions) and I had trouble consistently running my Python scripts with Visual Studio Code. One of the biggest problems I had with Code was learning how to run the Python code I was writing. While Code has a lot of good things going for it (more than most free IDEs) there can be some challenges, especially if you’re using Code for the first time. These features persuaded me to drop my previous IDEs and I’ve been using VSC almost exclusively for the last three years. Microsoft’s Visual Studio Code (VSC, or Code, for short) has quickly become one of the most popular code editors (i.e., integrated development environment, or IDE) because of its cross-cross platform capabilities, high level of customizable options, integrations for nearly all programming languages, and cost (it’s free!).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |