Тёмный

How To Create & Activate A Virtual Environment In Visual Studio Code (Python 3.12) 

Indently
Подписаться 211 тыс.
Просмотров 63 тыс.
50% 1

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 68   
@paulmoss4199
@paulmoss4199 11 месяцев назад
Thank you, that is very helpful. Is there a way to activate the VENV automatically when a new terminal window is opened?
@vincentlaizer
@vincentlaizer 11 месяцев назад
It could have been nice if you showed how to deactivate the virtual environment, great video btw ❤
@Indently
@Indently 11 месяцев назад
I will write this down for the next tutorial!
@Tora_Makun
@Tora_Makun 11 месяцев назад
I thought the same thing, just tried `exit` and it worked for me
@Nordlys0
@Nordlys0 8 месяцев назад
I prefer to use virtualenv instead of venv from a terminal/cmd/powershell, which is better and faster for some reasons. Some say it's the same, which is not the case at all.. So I've not tried virtualenv inside of VScode and give it a try.
@KoljaMineralka
@KoljaMineralka 6 месяцев назад
It would be nice if you created Best Practices playlist and gather all this tips, like using __name__ == __main__, creating virt env when starting new project etc...
@Indently
@Indently 11 месяцев назад
Here are the commands: Mac OS: python3 -m venv .venv source .venv/bin/activate Windows: python -m venv .venv .\.venv\Scripts\activate (Please correct me if I'm wrong for Windows, I will update this comment)
@SiddharthSharma-cp5vk
@SiddharthSharma-cp5vk 11 месяцев назад
in vs code you can create and activate virtual environment using command panel too
@diegolramirez
@diegolramirez 11 месяцев назад
In Windows Activate goes with capital "A" -> .venv\Scripts\Activate
@sayenation
@sayenation 11 месяцев назад
I have just done it yesterday. Depending on which shell you use it might be correct. For example in Powershell you need to ".\.venv\Scripts\Activate.ps1" and also enable scripts in powershell. But scripts in PS is another topic
@hannesweichselbaum2038
@hannesweichselbaum2038 11 месяцев назад
.\.venv\Scripts\Activate
@braydenmchan
@braydenmchan 11 месяцев назад
You might want to run the windows command to check the .venv directory since I believe that "python -m venv .venv" and "py -m venv .venv" produce different folder structures in .venv
@NiceChange
@NiceChange 11 месяцев назад
You made it so simple that it instantly became a new muscle memory command...THANKS!!!
@pablofueros
@pablofueros 11 месяцев назад
Personally, in vscode y prefer creating and activating a virtual enviroment using the "create environment" command
@neethugeorge7501
@neethugeorge7501 2 месяца назад
Thanks a ton :) Is there a way to activate the VENV automatically when a new terminal window is opened? (.venv) is not coming when we open Terminal after closing the IDE. @Indently Plz reply
@josericardoochoa3126
@josericardoochoa3126 2 месяца назад
Excuse me, friend, I would like to ask you for help because when I try to create a virtual environment and write the python location in the terminal, I get the following error "Set-location: No position parameter found", just, I would like to know what mistake I made so that it does not detect it
@diegogutierrezraghunath9315
@diegogutierrezraghunath9315 4 месяца назад
super helpfull, however one question i have is if I close vs code, how to I get back into the virtual environment(windows)
@larsthomsen6434
@larsthomsen6434 5 месяцев назад
thank you, this was simple and easy to follow
@codename_Rahul
@codename_Rahul 8 месяцев назад
This video was really helpful. Thanks!
@Tcrrxzz
@Tcrrxzz 11 месяцев назад
This helped me out a lot. Thanks!
@Confusedcapybara8772
@Confusedcapybara8772 6 месяцев назад
but how do you keep the venv actively when trying to run the app in debug mode, with the run button in the top right of vs code?
@gohilurvish
@gohilurvish 7 месяцев назад
I made some python based tools for our team and had a git repo for it. Everytime someone new joins, I needed to get them install needed libs and sometime conflicts happen. Since I found venv, the issue is partially solved. But now I face the issue on how to manage the venv with git. A tutorial for that would be appreciated.
@sohamjha7578
@sohamjha7578 2 месяца назад
its in my d drive so i would write d instead of c an ?
@prior2915
@prior2915 7 месяцев назад
so would using pipenv shell be the same thing or are there any major difference?
@krishj8011
@krishj8011 3 месяца назад
Thanks... Great tutorial
@kunalsoni7681
@kunalsoni7681 11 месяцев назад
love to watch your python videos :)
@JoanApita
@JoanApita 11 месяцев назад
man thank you this is what im looking for.
@rsKayiira
@rsKayiira 9 месяцев назад
Excellent explanation thank you
@KoljaMineralka
@KoljaMineralka 6 месяцев назад
it doesn't see pip :( in VS code, even though I installed it in virt env as per tutorial
@anphanhoang5308
@anphanhoang5308 11 месяцев назад
Hello sir, when i use javascript in vs code and ctrl + s to save my code it will auto help me auto formatting, how can i do the same thing with python (.py file) in vscode
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 11 месяцев назад
Useful content 👍. Venv is good as built-in feature. Personally i prefer Pipenv 😁
@Indently
@Indently 11 месяцев назад
I never explored anything else other than the built-in; any particular reason your prefer pipenv?
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 11 месяцев назад
@@Indently Pipenv is: 1. More automatic, one command (`pipenv install`) creates virtual environment and file with dependices 2. Just type `pipenv shell` to activate environment 3. New module installation adds depedicies automatically 4. Type just `exit` to deactivate environment 5. If You want clone virtual environment on other computer just paste depedicies file (`Pipenv.lock`) and type `pipenv sync`. 6. To remove environment just type `pipenv --rm` 7. You can create a requirements.txt file for venv It is worth trying `pipenv`, at most it will not appeal to you.
@Indently
@Indently 11 месяцев назад
Thanks for sharing, I will take a dive into it!
@JosephAlnasl
@JosephAlnasl 3 месяца назад
Great tutorial
@Showtime_007
@Showtime_007 11 месяцев назад
Love your content ❤
@marcostark8926
@marcostark8926 2 месяца назад
Doesnt work
@kishanbsh
@kishanbsh 11 месяцев назад
For the virtual environment folder is ".venv" the standard? I have seen some projects use "venv" as the folder name
@Indently
@Indently 11 месяцев назад
I know that the "." makes the folder invisible on Mac OS, but to be honest it's just what I've been doing since I started programming in Python. I would love to hear from someone else whether there's any benefit of doing that other than hiding folders for a cleaner directory.
@JeremyLangdon1
@JeremyLangdon1 11 месяцев назад
The “.” is helpful for alphabetical ordering as well. “venv” gets mixed in with other folders while “.venv” is at the top. It also makes it more explicit that it is not meant to be part of the codebase but rather a supporting config type folder… similar to the .vscode, .git folders, etc.
@jagadishdasari6466
@jagadishdasari6466 6 месяцев назад
Fantastic...
@KrAsHeDD
@KrAsHeDD 11 месяцев назад
The command for windows doesn't work for me. I've been trying to activate mine in vscode even before you uploaded this video. It says and error message "cannot be loaded be because the running script is disabled in this system" Despite several stackoverflow questions, it doesn't help still. Cmd command works fine but powershell doesn't.
@Indently
@Indently 11 месяцев назад
Someone else correct me if I'm wrong since I don't have Windows, but it sounds like this is more a setting that has to do with the security settings on your computer?
@KrAsHeDD
@KrAsHeDD 11 месяцев назад
@@Indently you're probably right too because it the same command I found on other places. I guess there are settings to be done to tackle the issue.
@mentalwall
@mentalwall 11 месяцев назад
But the better solution is to use WSL with VSCode - solves many compatibility issues
@alfredolagaray
@alfredolagaray 11 месяцев назад
Maybe it has something to do with execution policies. Run powershell as admin and try the command Set-ExecutionPolicy -ExecutionPolicy Unrestricted and try again the activate command.
@KEN-nh7om
@KEN-nh7om 9 месяцев назад
@@alfredolagaray This helped so much, thank you!
@sahillimba4585
@sahillimba4585 11 месяцев назад
Love you bro❤
@AlonsoLayena
@AlonsoLayena 3 дня назад
Muchas gracias!!!!
11 месяцев назад
What are the advantages of using this virtual environment instead of regularly installing the package you want to use?
@vincentlaizer
@vincentlaizer 11 месяцев назад
It helps you separate your code when working with same modules but of different versions, that's just one advantage
@darrenlefcoe
@darrenlefcoe 11 месяцев назад
Actually, it's a great question. The number of cases where the regular install is sufficient far outweighs the cases where venv is useful (plus it is clunky to use even with a great explanatory video like this). ...so I rarely use venv. I would be interested to hear good use cases other than encapsulation of packages (which can be achieved with a simple requirements.txt file).
@darrenlefcoe
@darrenlefcoe 11 месяцев назад
​@vincentlaizer I agree with this, but still prefer to avoid...
@-ese.soy.yo-
@-ese.soy.yo- 11 месяцев назад
Next video: How to deactivate venv. (Congratulations for a great channel)
@brien.
@brien. 5 месяцев назад
just type deactivate on windows
@athirariijil4303
@athirariijil4303 4 месяца назад
how to deactivate virtual environment in mac (in different shell)
@hamzahassan6726
@hamzahassan6726 10 месяцев назад
legend
@JeremyLangdon1
@JeremyLangdon1 11 месяцев назад
You didn’t really describe why virtual environments are helpful. Could be useful to describe using a requirements file in conjunction with a virtual environment. My preference for managing my virtual environments and dependencies is Poetry.
@Indently
@Indently 11 месяцев назад
I actually didn't describe why they are helpful at all, but I covered how to create and activate them. I will consider the rest for another tutorial :)
@mehdimj_ir
@mehdimj_ir 11 месяцев назад
This is nice, but please continue with Flet and create a real application.
@Indently
@Indently 11 месяцев назад
I will upload plenty of them, but it's not the only thing I will upload on this channel ;)
@SiddharthSharma-cp5vk
@SiddharthSharma-cp5vk 11 месяцев назад
know already
@Indently
@Indently 11 месяцев назад
Impressive!
@ButchCassidyAndSundanceKid
@ButchCassidyAndSundanceKid 11 месяцев назад
Can you do a tutorial running a python virtual environment inside docker please, I'd like to use it as my development environment. Thanks.
@TheMusterionOfRock
@TheMusterionOfRock 11 месяцев назад
We do this at work. Our conclusion was that inside docker a virtual environment makes no sense, because you are already in an isolated environment.
@Lord_Shan
@Lord_Shan 11 месяцев назад
Continuing with this topic, it's worth mentioning the use of pip freeze > requirements.txt to generate a list of installed packages and their versions and the subsequent installation of these packages from the generated requirements.txt file.
@Lord_Shan
@Lord_Shan 11 месяцев назад
@@squishy-tomato 👍Certainly, Poetry offers distinct advantages over pip. However, for beginners and a general understanding of virtual environments and package installation for their projects, using pip is entirely sufficient.
Далее
New In Python 3.12: @override
4:06
Просмотров 23 тыс.
Python Virtual Environment and pip for Beginners
30:39
А вы играли в school boy runaway?
00:30
Просмотров 149 тыс.
The Complete Guide to Python Virtual Environments!
15:52
Best way to create a virtual environment IN vscode
6:14
How to Set up VS Code for Data Science & AI
22:53
Просмотров 310 тыс.
5 Useful F-String Tricks In Python
10:02
Просмотров 308 тыс.
God-Tier Developer Roadmap
16:42
Просмотров 7 млн
Virtual Environments in Python - Crash Course
13:33
Просмотров 94 тыс.