0

Is it necessary every time after shutdown I need to create virtual environment for the Django project I'm doing. correct me in Some ways possible .

  • 3
    No environment are created once but you need to activate it each time you restart your process. – jlandercy Oct 15 '22 at 16:29
  • 1
    take a look here. you will understand what and how to use `virtual env` https://stackoverflow.com/a/41972262/16250404 – Hemal Patel Oct 15 '22 at 17:08

1 Answers1

1

When you create a virtual environment you can activate it (go inside to Venv), after finishing your job or want to change virtual environments you can deactivate it (exit from it ), and you can activate it again every time you want . You dont have to create it agian. Just activate it.

look at this example

$ mkdir client-old
$ cd client-old
$ python3 -m venv venv --prompt="client-old"
$ source venv/bin/activate
(client-old) $ python -m pip install django==2.2.26
(client-old) $ python -m pip list
Package    Version
---------- -------
Django     2.2.26
pip        22.0.4
pytz       2022.1
setuptools 58.1.0
sqlparse   0.4.2
(client-old) $ deactivate

$ cd ..
$ mkdir client-new
$ cd client-new
$ python3 -m venv venv --prompt="client-new"
$ source venv/bin/activate
(client-new) $ python -m pip install django==4.0.3
(client-new) $ python -m pip list
Package    Version
---------- -------
asgiref    3.5.0
Django     4.0.3
pip        22.0.4
setuptools 58.1.0
sqlparse   0.4.2
(client-new) $ deactivate
$ cd client-old
$ python3 -m venv venv --prompt="client-old"
$ source venv/bin/activate
(client-old) $  #this activate again good luck

Source

Useful link

MehrdadLinux
  • 448
  • 4
  • 13