Check Python installation path:
where python
Before Installating Python, verify wheather it is already installed on our system using where python command.
Check Python Version
python -V
navigate to the path returnd by
Installing Python
Navigate to the Offical Python download site and download Python.
Do the following while installation:
- Select Custom Installation Option.
- Checked Install for All users from Advance Section of installation.
- Checked Add Python to enviornment veriable from Advance Section of installation.
Open Python Interpretor from Command Prompt
- Open Command Prompt and navigate to the installed python path and run the following command.
python => it will open python interpretor.
exit() => it will exit us from the interpretor.
Python Virtual Environment:
- Benefits of using Python Virtual Environment
- A way to keep projects isolated.
- Different versions of libraries / packages.
- Different versions of Python.
- Project Organization.
- Keep default Python clean.
- multiple projects that depend on same library but different versions.
Create virtual environment using venv(Python 3):
python -m venv C:\path\to\new\virtual_env
Activate Virtual Environment:
C:\path\to\new\virtual_env\Scripts>activate.bat
Install packages into Virtual Environment:
pip install [packages-name]
Example:
pip install requests
pip freeze:
pip freeze
pip freeze will return the list of packages that we installed to a perticular virtual enviornment.