Python Forum

Full Version: Different Virtual environments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to Python and was wondering what differences there are in creating a virtual env in either Pycharm or through virtualbox or through the command line using virtualenv .

Huh
VirtualBox is for running OS isolated,example you run Windows and then can run a Linux distro eg Ubuntu in VirtualBox.

The main purpose of Python virtual environments is to create an isolated environment for Python projects.
This means that each project can have its own dependencies,regardless of what dependencies OS Python has or other project have.
Virtual environments is now build into Python trough venv or 3-party package like pipenv.
Quick demo:
# Make 
C:\
λ python -m venv my_env

# Cd in
C:\
λ cd my_env

# Activate
C:\my_env
λ C:\my_env\Scripts\Activate

# Check pip
(my_env) C:\my_env
λ pip -V
pip 10.0.1 from c:\my_env\lib\site-packages\pip (python 3.7)

# Install
(my_env) C:\my_env
λ pip install Flask
Collecting Flask
...........
Successfully installed Flask-1.0.2 Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.14.1 click-6.7 itsdangerous-0.24

# List dependencies
(my_env) C:\my_env
λ pip list
Package        Version
-------------- -------
click          6.7
Flask          1.0.2
itsdangerous   0.24
Jinja2         2.10
MarkupSafe     1.0
pip            10.0.1
setuptools     39.0.1
six            1.10.0
Werkzeug       0.14.1
(my_env) C:\my_env
Running python my_script.py it will only see dependencies in virtual environment my_env.