Comment Your Questions in Related Category

How to create a Python virtual environment for a new project

How to create a Python virtual environment for a new project







 

Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\user> cd F:\
PS F:\> mkdir DEV


    Directory: F:\


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/13/2022   5:47 PM                DEV


PS F:\> cd DEV
PS F:\DEV> mkdir project


    Directory: F:\DEV


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/13/2022   5:48 PM                project


PS F:\DEV> cd project
PS F:\DEV\project> python -m venv env
PS F:\DEV\project>



PS F:\DEV\project> cd env
PS F:\DEV\project\env> dir


    Directory: F:\DEV\project\env


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/13/2022   5:49 PM                Include
d-----         8/13/2022   5:49 PM                Lib
d-----         8/13/2022   5:49 PM                Scripts
-a----         8/13/2022   5:49 PM             91 pyvenv.cfg


PS F:\DEV\project\env> cd Scripts
PS F:\DEV\project\env\Scripts> dir


    Directory: F:\DEV\project\env\Scripts


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         8/13/2022   5:49 PM           2056 activate
-a----         8/13/2022   5:49 PM            985 activate.bat
-a----         8/13/2022   5:49 PM          22159 Activate.ps1
-a----         8/13/2022   5:49 PM            393 deactivate.bat
-a----         8/13/2022   5:49 PM         106348 pip.exe
-a----         8/13/2022   5:49 PM         106348 pip3.10.exe
-a----         8/13/2022   5:49 PM         106348 pip3.exe
-a----         8/13/2022   5:49 PM         264176 python.exe
-a----         8/13/2022   5:49 PM         252912 pythonw.exe


PS F:\DEV\project\env\Scripts>


Then continue with vscode.

 You can open vscode by right-clicking on the project folder and then using open with vscode.
You can create a new folder e.g "project_A".
You can create a new module with the extension .py e.g "Helloworld.py" inside your new folder. vscode code editor automatically will generate the extuated for your new module.

You can see continue in e.g_p-( 4 ), e.g_p-( 5 ), e.g_p-( 6 ) and e.g_p-( 7 )


e.g_p-( 4 )




e.g_p-( 5 )



e.g_p-( 6 )


e.g_p-( 7 )


If you encounter the following situation or problem:
PS F:\DEV\project> & f:/DEV/project/env/Scripts/Activate.ps1 & : File F:\DEV\project\env\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS F:\DEV\project> & f:/DEV/project/env/Scripts/Activate.ps1
& : File F:\DEV\project\env\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ & f:/DEV/project/env/Scripts/Activate.ps1
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS F:\DEV\project> & f:/DEV/project/env/Scripts/python.exe f:/DEV/project/projent_A/Helloworld.py
Hello World
PS F:\DEV\project> 

This is "How to create a Python virtual environment for a new project"

  • လေ့လာချင်တဲ့ သူများအတွက် ကျွန်တော့်ရဲ့ Tutorial မှာ လေ့လာနိုင်ပါတယ်။
Post a Comment