[{"data":1,"prerenderedAt":183},["ShallowReactive",2],{"content-query-LSwNSEgSCJ":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"tags":10,"body":11,"_type":177,"_id":178,"_source":179,"_file":180,"_stem":181,"_extension":182},"/tutorials/python-venv","tutorials",false,"","Python Virtual Environment (venv)","A Python Virtual Environment (venv) creates a local environment for your project dependencies (packages), completely detached from the system.\nThis isolates your project's packages from the system's in order to prevent version conflicts, and allows you to keep track of only the requirements your project demands.\nTo set up a local virtual environment, go to your Python project folder, then run:","python",{"type":12,"children":13,"toc":172},"root",[14,32,71,76,97,110,140,147,152,166],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19,22,30],{"type":20,"value":21},"text","A ",{"type":15,"tag":23,"props":24,"children":28},"a",{"href":25,"rel":26},"https://docs.python.org/3/library/venv.html",[27],"nofollow",[29],{"type":20,"value":8},{"type":20,"value":31}," creates a local environment for your project dependencies (packages), completely detached from the system.\nThis isolates your project's packages from the system's in order to prevent version conflicts, and allows you to keep track of only the requirements your project demands.\nTo set up a local virtual environment, go to your Python project folder, then run:",{"type":15,"tag":33,"props":34,"children":38},"pre",{"className":35,"code":36,"language":37,"meta":7,"style":7},"language-bash shiki shiki-themes github-light monokai monokai github-light monokai","python -m venv venv/\n","bash",[39],{"type":15,"tag":40,"props":41,"children":42},"code",{"__ignoreMap":7},[43],{"type":15,"tag":44,"props":45,"children":48},"span",{"class":46,"line":47},"line",1,[49,54,60,66],{"type":15,"tag":44,"props":50,"children":52},{"style":51},"--shiki-default:#6F42C1;--shiki-dark-mode:#A6E22E;--shiki-sky-dark-mode:#A6E22E;--shiki-light-mode:#6F42C1;--shiki-blue-mode:#A6E22E",[53],{"type":20,"value":10},{"type":15,"tag":44,"props":55,"children":57},{"style":56},"--shiki-default:#005CC5;--shiki-dark-mode:#AE81FF;--shiki-sky-dark-mode:#AE81FF;--shiki-light-mode:#005CC5;--shiki-blue-mode:#AE81FF",[58],{"type":20,"value":59}," -m",{"type":15,"tag":44,"props":61,"children":63},{"style":62},"--shiki-default:#032F62;--shiki-dark-mode:#E6DB74;--shiki-sky-dark-mode:#E6DB74;--shiki-light-mode:#032F62;--shiki-blue-mode:#E6DB74",[64],{"type":20,"value":65}," venv",{"type":15,"tag":44,"props":67,"children":68},{"style":62},[69],{"type":20,"value":70}," venv/\n",{"type":15,"tag":16,"props":72,"children":73},{},[74],{"type":20,"value":75},"To activate the new environment:",{"type":15,"tag":33,"props":77,"children":79},{"className":35,"code":78,"language":37,"meta":7,"style":7},"source venv/bin/activate\n",[80],{"type":15,"tag":40,"props":81,"children":82},{"__ignoreMap":7},[83],{"type":15,"tag":44,"props":84,"children":85},{"class":46,"line":47},[86,92],{"type":15,"tag":44,"props":87,"children":89},{"style":88},"--shiki-default:#005CC5;--shiki-dark-mode:#66D9EF;--shiki-sky-dark-mode:#66D9EF;--shiki-light-mode:#005CC5;--shiki-blue-mode:#66D9EF",[90],{"type":20,"value":91},"source",{"type":15,"tag":44,"props":93,"children":94},{"style":62},[95],{"type":20,"value":96}," venv/bin/activate\n",{"type":15,"tag":16,"props":98,"children":99},{},[100,102,108],{"type":20,"value":101},"To install requirements from a ",{"type":15,"tag":40,"props":103,"children":105},{"className":104},[],[106],{"type":20,"value":107},"requirements.txt",{"type":20,"value":109}," file:",{"type":15,"tag":33,"props":111,"children":113},{"className":35,"code":112,"language":37,"meta":7,"style":7},"pip install -r requirements.txt\n",[114],{"type":15,"tag":40,"props":115,"children":116},{"__ignoreMap":7},[117],{"type":15,"tag":44,"props":118,"children":119},{"class":46,"line":47},[120,125,130,135],{"type":15,"tag":44,"props":121,"children":122},{"style":51},[123],{"type":20,"value":124},"pip",{"type":15,"tag":44,"props":126,"children":127},{"style":62},[128],{"type":20,"value":129}," install",{"type":15,"tag":44,"props":131,"children":132},{"style":56},[133],{"type":20,"value":134}," -r",{"type":15,"tag":44,"props":136,"children":137},{"style":62},[138],{"type":20,"value":139}," requirements.txt\n",{"type":15,"tag":141,"props":142,"children":144},"h3",{"id":143},"deactivating-a-virtual-environment",[145],{"type":20,"value":146},"Deactivating a virtual environment",{"type":15,"tag":16,"props":148,"children":149},{},[150],{"type":20,"value":151},"To deactivate a venv and return to the system's python environment:",{"type":15,"tag":33,"props":153,"children":155},{"className":35,"code":154,"language":37,"meta":7,"style":7},"deactivate\n",[156],{"type":15,"tag":40,"props":157,"children":158},{"__ignoreMap":7},[159],{"type":15,"tag":44,"props":160,"children":161},{"class":46,"line":47},[162],{"type":15,"tag":44,"props":163,"children":164},{"style":51},[165],{"type":20,"value":154},{"type":15,"tag":167,"props":168,"children":169},"style",{},[170],{"type":20,"value":171},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html.dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html .sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html.sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html .light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html.light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html .blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}html.blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}",{"title":7,"searchDepth":173,"depth":173,"links":174},2,[175],{"id":143,"depth":176,"text":146},3,"markdown","content:tutorials:python-venv.md","content","tutorials/python-venv.md","tutorials/python-venv","md",1793934184840]