In this blog post we will see how to use different python versions on same machine using virtualenv. In this example we will use python 3.8.
virtualenv for python is like sandbox which completely isolates your development environment. so that you can maintain different python versions for your different projects.
1) install python 3 from here :
https://www.python.org/downloads/
note: do not add
this to path variable , it can create issue at later stages. Also keep note of installation
path for current python installation , we would need this while creating virtulenv.
2) open cmd and install virtualenv : pip install virtualenv
3) create a folder where you want to create your virtual
env.
4) create a virtual env named "venv" with python3
: virtualenv venv -p C:\Python3\python.exe
5) start virtual env : .\venv\Scripts\activate.bat
6) if you have "requirements.txt" then install your python modules from "requirements.txt" : pip install -r requirements.txt
7) if you wish to create "requirements.txt" : pip freeze >
requirements.txt
8) stop current virtual env : .\venv\Scripts\deactivate.bat
Ref : https://www.c-sharpcorner.com/article/steps-to-set-up-a-virtual-environment-for-python-development/
Let me know what topics you would like to read.
No comments:
Post a Comment