How to Run Python Code Directly in the Terminal or Command Line

Published: 20 July 2023
on channel: Basic Computational Tools
65
3

Full description at this link: https://basiccomputationaltools.blogs...

Sometimes it is useful and efficient to run some Python script directly in terminal or command line. For example, if you have installed a library and you would like to test if it has been installed successfully without explicitly launching Python Console.

One of the common examples is installation of PyTorch or TensorFlow with or without cuda support. You can test this without explicitly launching Python console using the following command.

Please note that when you are using Python with the '-c' or 'cmd' option each line of a normal Python code is followed by a semi-colon. For example, in a normal Python script in a Python Console you will first run 'import torch' followed by 'print(torch.cuda.is_available()'. This will return True if torch is installed with cuda support otherwise it will return False.

Run 'python --help' for more information.

Chapters:
00:00 Introduction
01:25 Determine numpy version directly in command line
02:46 Determine if torch is installed with cuda support
03:34 Determine if tensorflow is installed with GPU support


On this page of the site you can watch the video online How to Run Python Code Directly in the Terminal or Command Line with a duration of hours minute second in good quality, which was uploaded by the user Basic Computational Tools 20 July 2023, share the link with friends and acquaintances, this video has already been watched 65 times on youtube and it was liked by 3 viewers. Enjoy your viewing!