HOW TO ADD PYTHON TO PATH?
ADD PYTHON TO PATH
There is an application for anything you can think of. The world of applications has grown tremendously that there are numerous applications for anything and everything, be it in the form of a web application or one that runs on our smartphone. And for that Python is the most obvious choice for many developers across the world. The reason for its popularity is undoubtedly its features.
For many beginners, the problem comes when they install Python in Windows without fulfilling the prerequisites first. And they need to know how to add the path in Python.
FLAVORS OF PYTHON
Python is supported by all the operating systems that are currently in existence, but prominently, Linux, Mac OS, and Windows.
The updated version of Python that is available for download is very easy to install. You just need to download the binary code that is applicable to your operating system. And you have to install the same. If you find that the binary code is unavailable for the operating system that you are using, you have to make use of a C compiler to compile the source code manually. An advantage of compiling your source code manually is that you will get more flexibility in terms of features that you might need during the installation process.
SETTING UP PATH
Once you have installed Python on your system, you have to set up the path which is a tricky path. Depending on the operating system you are currently using, the process of setting up varies greatly.
ADDING PYTHON PATH TO WINDOWS
In most cases, there is a chance that the Python executable file wasn’t added to the Windows Path variable if you have installed Python in Windows like most other developers by just following online tutorials. The Python executable file is responsible for listing the directories that will be executed when you type in a command in the command prompt of your Python window. You will be able to access the python.exe file simply by typing the python keyword, once you have added the Python executable file in the Windows directory. The major advantage of adding this feature is that whenever you need to access the python.exe file, you don’t have to specify the full path to the program.
HOW TO ADD PYTHON PATH TO WINDOWS?
- Start the Run function on your Windows by using shortcuts ctrl+R.
- Once the Run prompt is up and running, type in sysdm.cpl
- Press Enter and you will be redirected to System Properties. In this section, locate the Advanced Tab and click on the button that reads Environment Variables.
- Under Environment Variables, find System Variables and locate the Path.
- Click on Edit and locate the option which says Variable Value. In this section add the path at the end of the phrase that is already present. You have to note that before you add the Path you need to include a semicolon(;) so that both can be differentiated easily and quickly.
- Once this is done, press OK and the path will be added to the specific location.
- Save all your actions and reboot your system for more effective performance.
SETTING PATH IN UNIX OR LINUX
1.In the csh shell, type the following sentence:
PATH”$PATH:/usr/local/bin/python” and press Enter.
2.If you are using the standard flavor of Linux, open up the bash shell and type the following phrase, export PATH= “$PATH:/usr/local/bin/python” and press Enter.
- If you have access to either sh or ksh shell, then open up the terminal and type the following, PATH= “$PATH:/usr/local/bin/python” and press Enter.
One of the important things to note when you are adding Path to Python in Unix/Linux is that, /usr/local/bin/python is the default path of the Python directory.
Some of the most significant Environment Variables that Python recognizes are,
- Pythonpath:-This is the most important Environment Variables that Python recognizes. It has a similar role to the original path. It tells Python where to locate the module files and how to import them into a program. Be sure to include the Python source library directory that contains the Python source code. In some cases, it is already pre-set in the Python directory.
- Python start-up:- It contains the path of an initialization file which contains the Python source code. This function is executed every time you start the interpreter in Python.
- Python caseok:- This Environment Variable is specific to Windows. When you use this variable, Python will find the first case insensitive match in an import statement.
- Python home:- This is an alternative to a module search path that can be used in Python. This is embedded into the PYTHONSTARTUP or PYTHONPATH in order to make switching modules between libraries fairly easy.
Apponix Offers Python Training in Bangalore