This is an article where the main focus is about activating a virtual environment for executing python in Microsoft Windows. The execution of the python virtual environment will be possible if only there is already one of it. In order to to create a new python virtual environment, there are several requirements to do it. Just read the article with the title of ‘How to Create a Python Virtual Environment in Microsoft Windows’ in this link. Just follow all the steps below :
1. Make sure that there is a python executable binary command for further execution in the command line.
2. Make sure that there is already a virtual environment folder with file with the name of ‘activate.bat’ inside of the Scripts folder. The following is the actual structure of the virtual environment folder created :
C:\python-win\myenv>dir Volume in drive C is Windows Volume Serial Number is E003-3593 Directory of C:\python-win\myenv 04/02/2020 01:38 PM <DIR> . 04/02/2020 01:38 PM <DIR> .. 04/02/2020 01:31 PM <DIR> Include 04/02/2020 01:31 PM <DIR> Lib 04/02/2020 01:38 PM 237 pyvenv.cfg 04/02/2020 01:38 PM <DIR> Scripts 1 File(s) 237 bytes 5 Dir(s) 253,969,395,712 bytes free C:\python-win\myenv>cd ..
3. Make sure that there is already a virtual environment folder with file with the name of ‘activate.bat’ inside of the Scripts folder as follows :
C:\python-win\privenv>cd Scripts C:\python-win\privenv\Scripts>dir Volume in drive C is Windows Volume Serial Number is E003-3593 Directory of C:\python-win\privenv\Scripts 04/13/2020 11:15 PM <DIR> . 04/13/2020 11:15 PM <DIR> .. 04/13/2020 11:15 PM 2,287 activate 04/13/2020 11:15 PM 961 activate.bat 04/13/2020 11:15 PM 18,093 Activate.ps1 04/13/2020 11:15 PM 368 deactivate.bat 04/13/2020 11:15 PM 103,291 easy_install-3.8.exe 04/13/2020 11:15 PM 103,291 easy_install.exe 04/13/2020 11:15 PM 103,273 pip.exe 04/13/2020 11:15 PM 103,273 pip3.8.exe 04/13/2020 11:15 PM 103,273 pip3.exe 04/13/2020 11:15 PM 524,872 python.exe 04/13/2020 11:15 PM 523,848 pythonw.exe 11 File(s) 1,586,830 bytes 2 Dir(s) 236,000,317,440 bytes free C:\python-win\privenv\Scripts>
4. So, if the file is actually exist, just type it in the command line to execute it. The following is the command execution of ‘activate.bat’. This command will activate the python virtual environment and will change the prompt format. The change will indicate that the python virtual environment is currently active. The following is the actual execution of the ‘activate.bat’ file :
C:\python-win\myenv\Scripts>activate (myenv) C:\python-win\myenv\Scripts>