Download
Download latest version of python from python.org/downloads/
Install
Using the default location or any other folder path
Note: For windows, keep the folder path handy [where python is installed], which we will use later
Set environmental variable [winOS]
Open your environmental variable, under system variable section, append your python installed path
let’s say, I have installed under c:\python
then, set the environmental as
PATH = …….;c:\python;C:\python\Scripts
Note:
C:\python\Scripts is required, if you want to install any python package using pip command.
Verify Python
For Windows
Start | Run | cmd
enter python
you should see the result as
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
After the “>>>”, you can write any python script and press enter to see the output. [for practice]
Or just enter python --version
in command prompt, you will get the version if installed successfully.
For Mac OS
Open terminal and enter python3
, you should see the result as
skpatro~ % python3
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
and also you can get the version with command
python3 --version
Python IDLE – inbuilt shell editor
For Windows
Once you installed, you will get a default Python editor,
you can find it under Start | All programs | Python x.x | IDLE (python x.x)
and you can write a small script on python shell [IDLE] as shown in below screenshot and hit enter, you will see the result
For Mac OS
Shell editor for Mac can be found at Go > Applications > Python 3.x > IDLE
Setup virtual environment
Virtual environment is a folder other than the default python installation, where we can install all python libraries.
It’s recommended to create a virtual env
For Mac OS in terminal
python3 -m pip install -U pip #upgrade pip
python3 -m venv .venv #setup virtual env
source .venv/bin/activate #activate virtual env
For windows OS, in cmd
py -m pip install -U pip
py -m venv .venv
call .venv\\Scripts\\activate
Note:
Parameter venv
is for virtual environment & .venv
is the folder where we want to install all python libraries.
To verify the virtual environment setup, enter command
where python3 or python
This should result the folder where you have activated the venv.
Example –
(venv) UserName Sel_local % where python3
You can see the (venv) above, which identifies the virtual environemnt.
To know the version of pip
For windows –
py -m pip --version
For Mac OS –
python -m pip --version
Use “python3
” if you are using python > 3.0
Refer to know how to setup python project for pyCharm & Visual studio code
2 Comments