This turned my learning on virtual environments from “copying” to “understanding.” It’s such a gratifying feeling. Thank you. I lost sight of what I was doing in creating virtual environments and felt lost for a few days. This was so concise and clear. Again, thank you. Subbed.
As a second year CS student this was great. Everything made sense. After watching this I tried conda, hated it, switched to venv. Now I'm a happy Data Science learner thanks to you.
Yesss! We need this kind of information. There are thousands of guys who talk about a programming language, but very few who talk about the information that enables a project to move forward, to deliver. Thanks Jose. How about a video about conda and another one to compare both?
So when you "boot up a virtual environment", you're simply changing the system's environment variables, such as the PATH, so they point to folders in your virtual environment folder?
This 15 minutes are extremely useful for absolute beginners to virtual environments. You can go ahead and watch it carefully. I thank you sir,Jose for speaking clearly each step you do .
Excellect video that helped a lot. I'd just like to add; to create a requirements.txt file easily, run: pip3 freeze > requirements.txt. That will put all of the modules and versions in a file for you to edit or use to import into another virtual environment.
Thank You! This is one of those topics I feel no-one really explains. So you end up banging your head against a wall while following a tutorial steps exactly and getting error messages. So it's good you manged to explain how it works and why I should use virtual environments succinctly.
A tip for figuring out which version the command prompt is finding is to run the command: where python It'll return each python.exe it finds in the path in the order it would execute them, so the first line returned is the one that will run when you execute python. And now you know which folder will be the first valid python folder in your path.
This was exactly what was needed. Your explanation was crystal clear and solved a lot of problems I was having. Thank you for your expertise, time, and efforts. Cheers!
Thanks for the clear info. I'm a beginner and had to do a bit of Stack Overflowing to get the whole thing set up on Windows, like setting up the environment path and the execution policy. Cheers, thanks again!
Thanks, that was very clear, I ended up making such a mess of my python installation that I ended up reinstalling macos. Never that again, it cost me half a day wasting time on setting everything up again.
Great intro to virtual environments. To activate the virtual environment when using PowerShell, I had to run the command: venvName\Scripts\Activate.ps1 instead of venvName\Scripts\activate.bat
Brian good catch. Also, if it doesnt work you will need to set the execution policy to either Bypass or AllSigned. Bypass all scripts are allowed, Allsigned only trusted so when you run third party scripts you will have to trust them first. I ran in powershell 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' you can always reverse it to how it was whether it was restricted or undefined after completing your virtual environment project.
Incredible and Godsent video. I'am new with package installation and I was so nervous because I had absolutely no idea as to what exactly to do with virtual environment. Now, I've hit the ground running with virtual environments and some other important stuff! Much appreciated Jose!
Thank you for all the content you make Jose! Having access to short video lessons of this quality is such a luck for us. By the way, I’m almost done with The Complete Python Course and I must say that it is simply amazing, congratulations for what you have achieved with that.
Great video, thank you for the explanation. The video after all could be shortened to 2 steps (let it be a cheatsheet for me and others): 1) run C:\python\Python_3.6.4\python.exe -m venv .env 2) run 'activate.bat', for example, C:\Projects\Learning\Python\python_automation_mentoring\sandbox\pytest_example\.env\Scripts\activate.bat
You have helped me so much! I was looking for a guide like this for months, after I screwed with my dependencies. I finally found this video after I thought all hope was lost. I appreciate your hard work!
Is python virtual Env portable and transferable from one system to another OR from windows to Linux ? If it is then we can copy directory containing virtual Env in flash drive and work in any system.
Really clear, simple, and explains a lot of things that beginners never hear like path, creating venv with a specific python, how venv work, etc. Thx a lot
hey @teclado, a question. Can you use python inside one folder in windows only, without installing it system wide. I have to create app in python folder to be transferable to multiple windows system, for example windows server 2012, 2016... Is it possible to have everything needed in one folder with python interpreter, python env and "copy-paste" that folder to multiple Windows OS? How can I achieve that? I need to use win32com, openpyxl. Do I MUST have python installed in windows globally? THANK YOU
So to use different virtual environments, one could either install Python (multiple versions), A package manager (pip3), (And if running old python: pyenv, pyenv-virtualenv, pyenv-virtualenvwrapper) Then create/use virtual environments (via the built-in venv ). The alternative is to install Ana/Miniconda. btw, conda seems like a better approach than using pip for virtual environments. What a third way be to install nothing locally and instead point a browser to iPythonNotebook->Jupyter Notebook / JupyterLab? I need to sometimes build exes from 2 python versions.. Python 3.4.4 (32-bit for WinXP) and Python 3.11.1 (64-bit).. And that requires I run a windows setup exe or a whl to install a specific python package.. (for example PyQt 5.4 can't be installed via pip). Would installing packages this way be recognized by virtual environments (venv or anaconda), or be supported in JupyterLab?
Thank you for your easy explaination on virtual enviroment. If python is installed in C drive and my projects are located in D drive, can I create virtual enviroment in D ? or it should be in the drive where python is installed?
how would one upgrade the phyton in a virt environment? thanks? for instance my system wide python says it is 3.11.3 but my venv says it is 3.7. wld be grateful for any help or signposting
Hey Abdul, you'd delete the virtual environment and create another one. If you run `python` in the console and that's 3.11.3, then you can create a virtual env with `python -m venv .venv` (using the venv module to create a virtual environment called .venv). Before deleting the existing virtual environment, make sure you've made a file (usually called `requirements.txt`) that specifies all your project dependencies. Then it's easy to re-install all your deps in the new virtual environment with `pip install -r requirements.txt`.
I havent hit the subscribe button that hard in a long time, great video man. If you're taking requests, a tutorial to clean up global/local scopes for people that have installed way too many versions and their computer is totally out of wack. Moving forward Im going to take the extra 5 minutes and do everything local, thanks to you I now know why it's so important Edit: One issue when I run it it keeps using another interpreter and no matter how many times I changed it in vscode the same issue. I used sys.executable to confirm it's the wrong env
💥 thank you! I will continue making videos, I hope you enjoy them! And thanks for the suggestion, a guide on cleaning things up would be nice actually. I'll get to work! VSCode always chooses a default environment for me too. Then I create a virtual environment using the console and _sometimes_ it will be like "do you want to select this one?". Other times it won't, and you just have to remember to do so manually. CTRL+SHIFT+P -> Select Interpreter is the easiest way to do it (CMD+SHIFT+P on Mac).
when creating a new virtual environment doesn't that mean that all the packages you've installed before would need to be re-installed considering that it's an independant python copy ? and with each venv you'd need to install the same libraries more than once taking up unnecessary space in the process, is there a way around it ?
So what is the point of Requirements.txt if the whole idea for using this environment is so that it would already contain pre-downloaded dependencies and libraries that this specific project uses.
You can create a virtual env and install your dependencies, but if you want to share the project with others they won't have a virtual env. So what dependencies should they install when they create one? That's what the requirements.txt file stores.
I...... have never seen anyone use chdir. cd. it stands for change directory. it works on linux, windows, and mac. it's only two characters. I'm so confused.
Does Python has anything like NPM in JS land? --automatically add packages (+versions) to the requirements.txt file when i install something new? Besides that question, it was an awesome explanation for the topic.
awesome video!! now I have a clearer idea of virtual environment on python! do you have videos on making a client/server program to talk to a server and receive information from another server?
This turned my learning on virtual environments from “copying” to “understanding.” It’s such a gratifying feeling. Thank you. I lost sight of what I was doing in creating virtual environments and felt lost for a few days. This was so concise and clear. Again, thank you. Subbed.
Best coding tutorial video I have ever watched. Super high quality, incredibly clear
As a second year CS student this was great. Everything made sense. After watching this I tried conda, hated it, switched to venv. Now I'm a happy Data Science learner thanks to you.
Glad it helped! Thanks for the comment!
Conda can be helpful as well if you use it correctly.
Create seperate venvs from conda, and use it for multiple projects.
Please I can't move past 5:30... how do I grab the path to the installation package? Help me
smashin the like button dude, best video ive seen on this and im finally understanding after years!! thank you!!
Awesome, thank you! Happy to help!
Yesss! We need this kind of information. There are thousands of guys who talk about a programming language, but very few who talk about the information that enables a project to move forward, to deliver. Thanks Jose. How about a video about conda and another one to compare both?
So when you "boot up a virtual environment", you're simply changing the system's environment variables, such as the PATH, so they point to folders in your virtual environment folder?
Thats the first part of the virtual environment. You also create a copy of the interpreter with the packages specific to the new venv
@@sahilsagwekar gotcha, thanks!
Finally, an explanation on a topic : venvs
This 15 minutes are extremely useful for absolute beginners to virtual environments. You can go ahead and watch it carefully.
I thank you sir,Jose for speaking clearly each step you do .
I've been trying to learn to code on my own/online for nine months and this was the most valuable 15 minutes so far
Wish he said what program he was running all that code in. Nothing I open on any of the python options looks like that.
Excellect video that helped a lot. I'd just like to add; to create a requirements.txt file easily, run: pip3 freeze > requirements.txt.
That will put all of the modules and versions in a file for you to edit or use to import into another virtual environment.
Thank You! This is one of those topics I feel no-one really explains. So you end up banging your head against a wall while following a tutorial steps exactly and getting error messages. So it's good you manged to explain how it works and why I should use virtual environments succinctly.
Thank you very much Ronald! Understanding what’s going on behind the scenes is really useful, especially if you have to troubleshoot something 😅
This was the best crash course on virtual environments I've seen. The diagrams are crystal clear and your pace is amazing. Thank you!
Thank you very much! Glad you liked it 🚀
I used CTRL+SHIFT+C (when I opened my py script in VScode) to skip the first 3 steps. This video is amazing. Thank you so much!
A tip for figuring out which version the command prompt is finding is to run the command: where python
It'll return each python.exe it finds in the path in the order it would execute them, so the first line returned is the one that will run when you execute python. And now you know which folder will be the first valid python folder in your path.
"Which python" for mac and linux users 👍👍
I couldn't have found a better tutorial to get started, its really worth watching!
Nicely done. Just finished your WSL2 class on another training web site. Virtual Environments are a mystery no more, Thanks
I don't have any WSL2 classes 🤔 but thank you nonetheless, glad you liked the video!
quick and straight to the concept venv, dependency management using pip
I really appreciate the details. I would use this video as an example every time i am lost
This clarified what virtual environments are for me, thank you!
This is the best video for understand virutal enviroments from scratch, great video and thank you
Great video thanks, most tutorials seem to assume you know why we need to create a virtual environment.
This was exactly what was needed. Your explanation was crystal clear and solved a lot of problems I was having. Thank you for your expertise, time, and efforts. Cheers!
Glad it helped! Thank you!
Thanks for the clear info.
I'm a beginner and had to do a bit of Stack Overflowing to get the whole thing set up on Windows, like setting up the environment path and the execution policy.
Cheers, thanks again!
Very thorough explanation! Thank you for explaining how virtual environments work rather than just how to use them!!
Glad it was helpful! Thanks for the comment!
Thanks, that was very clear, I ended up making such a mess of my python installation that I ended up reinstalling macos. Never that again, it cost me half a day wasting time on setting everything up again.
Great intro to virtual environments. To activate the virtual environment when using PowerShell, I had to run the command: venvName\Scripts\Activate.ps1 instead of venvName\Scripts\activate.bat
Brian good catch. Also, if it doesnt work you will need to set the execution policy to either Bypass or AllSigned. Bypass all scripts are allowed, Allsigned only trusted so when you run third party scripts you will have to trust them first. I ran in powershell 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' you can always reverse it to how it was whether it was restricted or undefined after completing your virtual environment project.
Incredible and Godsent video. I'am new with package installation and I was so nervous because I had absolutely no idea as to what exactly to do with virtual environment. Now, I've hit the ground running with virtual environments and some other important stuff! Much appreciated Jose!
A very concise explanatory video, thank you for this.
This is best explanation I've seen in UA-cam about this topic. Thanks !
5:26 so that is the path to the python version 3 , .exe file is at. How would we find that path if we don't know where it is installed? (for MacOS)
Thank you for all the content you make Jose! Having access to short video lessons of this quality is such a luck for us.
By the way, I’m almost done with The Complete Python Course and I must say that it is simply amazing, congratulations for what you have achieved with that.
Thank you so much Félix! Im really happy that you’re enjoying the course!
I’ll continue making short videos and series as well! 💪
This video helped me a lot. Virtual environments always seemed scary to me but now I understand it.
Semver in Python - so much more intuitive than JS. Thank you, Python!
Thank you for the explanation. It is still incomprehensible how the python community (we belong to) has decided to live like this.
Great video, thank you for the explanation.
The video after all could be shortened to 2 steps (let it be a cheatsheet for me and others):
1) run C:\python\Python_3.6.4\python.exe -m venv .env
2) run 'activate.bat', for example, C:\Projects\Learning\Python\python_automation_mentoring\sandbox\pytest_example\.env\Scripts\activate.bat
Simple and clear explanation. Now I know what i'm doing and don't just copy and paste commands. Thank you very much!
Very well explained and with a lot of details. Easy even people which are not familiar with software developing. Thanks a lot !!
You have helped me so much! I was looking for a guide like this for months, after I screwed with my dependencies. I finally found this video after I thought all hope was lost. I appreciate your hard work!
this really brings clarity to my understanding
I love how you explain not just how to set up a virtual environment, but also why we do it. Great stuff :)
Excellent! Would you have any plans to share and demo use cases for streamlit ?
Kudos! Thanks for the quick and easy guide!
Are you required to deactivate after working in a virtual environment or is it enough just to change directory?
Is python virtual Env portable and transferable from one system to another OR from windows to Linux ?
If it is then we can copy directory containing virtual Env in flash drive and work in any system.
Thanks for a load of great tutorials and would you consider doing a series on Swift on the mac? thanks again
What a great video. Thank you very much. I did a resume to me.
Great presentation. Short but sufficiently detailed. Well done!
This is video is so easy to follow and helped me a great deal. Thank you very much man.
i finally understand how venv works,thank you , u are awsum
wonderful explanation of Venv and LIBDADies
Most needed video. Good explaination
great vid, well detailed and learned even more than just venv. Detail helped me get better grasp of how windows os and py work.
Awesome video with key bits of information that I've wanted answers to for a while that are difficult questions to ask the internet!
I've watch your udemy videos! This feels nostalgic haha.
Excellent video. I am really grateful for this dose of knowledge.
This was so beautifully and simply explained. Thank You for this video. Happy New Year
Really clear, simple, and explains a lot of things that beginners never hear like path, creating venv with a specific python, how venv work, etc. Thx a lot
thank you, bro! its very easy to understand, gl!
Great Explanation, I have ever perceived
Very helpful video!!! Just two things are missing: deactivation and deletion. But anyway, your video helped me a lot!!! Thank you.
Excellent tutorial and understanding. Thanks.
Glad it was helpful! Thank you!
Amazing video. Simple, clear and to the point with examples. Thank you!
Simple my ass
hey @teclado, a question. Can you use python inside one folder in windows only, without installing it system wide. I have to create app in python folder to be transferable to multiple windows system, for example windows server 2012, 2016... Is it possible to have everything needed in one folder with python interpreter, python env and "copy-paste" that folder to multiple Windows OS? How can I achieve that? I need to use win32com, openpyxl. Do I MUST have python installed in windows globally? THANK YOU
So to use different virtual environments, one could either install
Python (multiple versions),
A package manager (pip3),
(And if running old python: pyenv, pyenv-virtualenv, pyenv-virtualenvwrapper)
Then create/use virtual environments (via the built-in venv ).
The alternative is to install Ana/Miniconda. btw, conda seems like a better approach than using pip for virtual environments.
What a third way be to install nothing locally and instead point a browser to iPythonNotebook->Jupyter Notebook / JupyterLab?
I need to sometimes build exes from 2 python versions.. Python 3.4.4 (32-bit for WinXP) and Python 3.11.1 (64-bit).. And that requires I run a windows setup exe or a whl to install a specific python package.. (for example PyQt 5.4 can't be installed via pip). Would installing packages this way be recognized by virtual environments (venv or anaconda), or be supported in JupyterLab?
Fantastic! OMG, thank you for this! It really helped me understand how it works!
Awesome explanation. Appreciate for taking time to create it!
FINALLLLYYYY JESUS... I've been looking for you buddy thanks
Thank you for your easy explaination on virtual enviroment. If python is installed in C drive and my projects are located in D drive, can I create virtual enviroment in D ? or it should be in the drive where python is installed?
That was exactly what I was looking for! Thank you!
Glad I could help!
Thanks for the informative video. Is it possible to run multiple virtual envs on a single pc at the same time without interfering eachother?
Most helpful video on this topic 🙂
I learned a lot through your video. Tremendous help and such a quality! Thank you so much.
how would one upgrade the phyton in a virt environment? thanks?
for instance my system wide python says it is 3.11.3 but my venv says it is 3.7.
wld be grateful for any help or signposting
Hey Abdul, you'd delete the virtual environment and create another one.
If you run `python` in the console and that's 3.11.3, then you can create a virtual env with `python -m venv .venv` (using the venv module to create a virtual environment called .venv).
Before deleting the existing virtual environment, make sure you've made a file (usually called `requirements.txt`) that specifies all your project dependencies.
Then it's easy to re-install all your deps in the new virtual environment with `pip install -r requirements.txt`.
thank u for the video. ive learnd a lot from this, mainly about path
Glad it was helpful!
what if i want to install a package like angr and use it in different projects?
Thank you so so much, this was the best, concise, follow along video to me. It freed me from my virtual environment blockade. Gracias 🙏
Thanks for the explanations; good stuff!
I havent hit the subscribe button that hard in a long time, great video man.
If you're taking requests, a tutorial to clean up global/local scopes for people that have installed way too many versions and their computer is totally out of wack.
Moving forward Im going to take the extra 5 minutes and do everything local, thanks to you I now know why it's so important
Edit: One issue when I run it it keeps using another interpreter and no matter how many times I changed it in vscode the same issue. I used sys.executable to confirm it's the wrong env
💥 thank you! I will continue making videos, I hope you enjoy them! And thanks for the suggestion, a guide on cleaning things up would be nice actually. I'll get to work!
VSCode always chooses a default environment for me too. Then I create a virtual environment using the console and _sometimes_ it will be like "do you want to select this one?". Other times it won't, and you just have to remember to do so manually. CTRL+SHIFT+P -> Select Interpreter is the easiest way to do it (CMD+SHIFT+P on Mac).
when creating a new virtual environment doesn't that mean that all the packages you've installed before would need to be re-installed considering that it's an independant python copy ?
and with each venv you'd need to install the same libraries more than once taking up unnecessary space in the process, is there a way around it ?
Yep, installed packages take up space in each virtual environment!
What is the connection between the Python project to the Virtual Env. folder ?
So what is the point of Requirements.txt if the whole idea for using this environment is so that it would already contain pre-downloaded dependencies and libraries that this specific project uses.
You can create a virtual env and install your dependencies, but if you want to share the project with others they won't have a virtual env. So what dependencies should they install when they create one? That's what the requirements.txt file stores.
Thank you Sensei, easy to understand ... Oossh😁😸
Thank you so much. This was one of the best videos ever. 😊
great content , keep up the good work
Thnak you for this video, It is a very usefull video for me as a begginer
What an explanation ! Thank u !
I...... have never seen anyone use chdir.
cd. it stands for change directory. it works on linux, windows, and mac.
it's only two characters.
I'm so confused.
Don't worry about it :D
Same. I wanna roast him about it so bad!
Does Python has anything like NPM in JS land?
--automatically add packages (+versions) to the requirements.txt file when i install something new?
Besides that question, it was an awesome explanation for the topic.
Really clear explanation, thanks.
Muy completo con una sola tabla, tiene buen manejo con python. Gracias por compartir conocimiento
Thanks for the very clear and insightful video!
Great video! clear as water
Nice video, well presented including the visuals.
Nice work! Thanks 👍
Thank you!
Thanks a lot! It helped me build my own Venv!
Glad I could help!
awesome video!! now I have a clearer idea of virtual environment on python! do you have videos on making a client/server program to talk to a server and receive information from another server?
how can you get the path to your python installation on mac?
Super helpful for a new python programmer like me. Subbed, without hesitation. :D
Great, comprehensive tutorial! I really appreciated the extra tidbits of info, such as the explanation of version numbering, too. Thank you so much!