One of the main reasons I prefer R(Studio) over Python for doing data science in a context of business intelligence is the ease and stability of the workspace: no virtual environments to maintain since most popular libraries have matured. An update once a year suffices. Yet I acknowledge Python is a lot faster and more versatile. In this short post I discuss an error all new Python aspirants run into.
‘python’ is not recognized as an internal or external command, operable program or batch file.
If you’re sure you installed Python and you get this error, here’s what went wrong: you forgot to add Python to the PATH variable during the installation process.
What is the PATH variable. To cite Wikipedia: it’s a “a set of directories where executable programs are located.” In other words, Python is an application (.exe) and you need to tell your computer what you mean when you type python in a terminal.
Two things you can do. The first is reinstalling Python and checking the checkbox. The second is taking these easy steps to add Python to your PATH variable.
- Go to This PC
- Right click somewhere (not a folder)
- Click Properties
- Click Advanced System Settings
- Click Environment Variables
- Double-click the value of the Path variable in the System variables
- Click New
- Type the directory of where you installed Python
Congratulations, you can now run Python from the command prompt and PowerShell.