What is virtual environment in python?
A virtual environment is an isolated python environment created for a specific project.
it has :
- its own python interpreter
- its own installed packages
- its own package versions
Packages installed in on virtual environment do not affect
Compatibility of the one project to another project
one framework will support ,another framework will not support
For ex:- one project will support 3.15, old 3.15 ,LongChain will support 3.13 upto
so it will not support 3.14 the project will fail when you executed, for this over come the issue , we will built 3.13 or 312, project it self that is called virtual environment
Step1:
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> flask --version
Python 3.14.0
Flask 3.1.2
Werkzeug 3.1.5
Step2: Uninstall flask
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37.1> pip uninstall flask
Found existing installation: Flask 3.1.2
Step3: getting error ,Flask is global unstall,now we have to instal flask vituvally
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37.1> python app.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37.1\app.py", line 1, in <module>
from flask import Flask, jsonify, request
ModuleNotFoundError: No module named 'flask'
Step4: Flask install virtual for project specific
[Optional, if any issue Allow scripts only for your user]
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
Step5: Activate the python for virtual environment
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37>python -m venv ccit-env
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> ccit-env1\Scripts\activate
Step6: Install flask
(ccit-env1) PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> pip install flask
Step7: After install, project work with flask because of all libraries are loaded project itself
(ccit-env1) PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> python app.py
All Libararies
Step7: Come out from virtual environment enter deactivate
(ccit-env1) PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37> deactivate
PS C:\Users\Administrator\Desktop\CCIT\PythonCourse\Day37>
PyCharm Download
https://pycharm-community-edition.en.softonic.com/
3.5GB Storage required to install
AI Related (GIT-Hub Copilot,RAG,LangChain,LLMS - communication, ollma)
PyCharm tool ,automatically interpreter installed project level, choose your appropriate environment.
Install Flask
No comments:
Post a Comment