Python Tutorial: virtualenv and why you should use virtual environments

preview_player
Показать описание
In this video, we will be looking at virtualenv and why you should be using virtual environments in Python. Virtual Environments in Python allow us to keep project-specific dependencies in a separate place than our global site-packages. This is extremely useful when you have different versions of packages for different projects.

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python
Рекомендации по теме
Комментарии
Автор

commands #comments etc in above video...
0:30 $pip install virtualenv
1:20 $pip list #see ton of global packages...
2:00 $virtualenv project1_env
2:20 $source project1_env/bin/activate
2:40 (project1_env) #now inside virtual environment...
2:50 which python #locate location of python
3:08 which pip #locate location of pip
3:20 $pip list
3:25 $pip install numpy
3:40 $pip install pytz
3:45 $pip install psutil
3:55 $pip list
4:10 $pip freeze --local
4:40 $pip freeze --local > requirements.txt
4:45 $cat requirements.txt
5:05 $deactivate
5:15 $which python
5:25 $pip list
5:50 $rm -rf project1_env/
5:55 $ls
6:40 $virtualenv -p /usr/bin/python2.6 py26_env
7:00 $ls
7:05 $source py26_env/bin/activate #see new in brackets)
7:20 $which python #now python 2.6.9
7:45 $pip install -r requirements.txt #goes out and grabs pkgs!
7:55 $pip list #see pkgs installed!
8:35 ls #don't put project files inside virtual env (recommendation)
===

fred.c.johnston
Автор

On windows, make sure the current directory is your "your_current_env", and just run:
Scripts\activate
on Mac, the equivalent to activate is:
/bin/activate
To deactivate on windows, just run the above, but replace "activate" with "deactivate".
Also, the equivalent of the command "which" in Mac, is the command "where" in Windows. So on Windows you run:
where file_name

LazerScalper
Автор

The delivery is crystal clear.. Bro u so talented in both python and giving lectures, not to mention u r doing this for free. God bless you!

mmh
Автор

Just wanted to comment. 5 years later and what I had been stressing out about for a few hours now is easily explained in depth in the first 3 minutes of this video. Thank you very much!

iAreZombie
Автор

Wow. This is an EXCELLENT tutorial. I took notes, and now I feel like I know everything I need to get started using virtual environments. Thanks!

Enfors
Автор

6 years later and I can say this is a gold video! I was really struggling to understand virtualenv and you cleared almost all my questions with one single video. Thank you so much

noecuyuch
Автор

Schafer i must say, when it comes to python your channel is the best. The way you present is great. I thank you very much for producing python learning videos.

iftikharabid
Автор

Thank you Corey. Seriously, you've made learning all of this material (Python, pip, virtualenv, Jupyter) incredibly simple.

AlexChambersXYZ
Автор

Your tutorials are made of manna and indispensable in my learning python. Thank you.

itakithetree
Автор

If you have any random related questions while watching his videos, just wait and your answer will appear in the same video. You do a commendable job. Thanks for these lessons.

sagargoyal
Автор

This cleared up so many things related to all the "heavy lifting" options PyCharm has. Found it all a bit daunting until I watched this. Very clear explanation. Brought it back to basics of setting up different environments, as always Corey. Thank you!

MarcMcRae
Автор

I love your videos Corey. You are really good at only pulling out the foundational details and presenting them clearly.

cjhacker
Автор

thank you so much ! I was trying to understand it for a couple of hours before i found your video. Very good, very clear

JPabloDonayreQuintana
Автор

I'm a math teacher doing a sabbatical project. I'm a total newbie to Python. This video helped me wrap my head around a lot of stuff. Thanks so much!

HendreeMilward
Автор

8:31 is the answer I was looking for - keep the project files outside the virtual environment.
Overall, the video is excellent! Thank you.

rajatsrivastav
Автор

One key point right at the end, about what really gets separated in and out of the virtualenv. Thanks

bobjohnson
Автор

I'm glad you made that last point. That's exactly what I was looking for!

MatthewMcG
Автор

I just wanted to say; Thanks a lot for making these videos. You are a lifesaver!

shahzebafroze
Автор

This is a great video. Learn so much in a short amount of time and explained everything well. The information in the last 2 min of the video is what I needed the most ❤

peaceof_siesie
Автор

Very helpful for beginners to understand about Virtualenv and setup in their MAC. Thank you very much... Really appreciated!!!

kajarubansurendran