{"id":21470936,"url":"https://github.com/saadarazzaq/venvpy","last_synced_at":"2025-03-17T06:45:10.976Z","repository":{"id":197610127,"uuid":"698981434","full_name":"SaadARazzaq/venvpy","owner":"SaadARazzaq","description":"Python Virtual Environment Setup in all OS's ✅","archived":false,"fork":false,"pushed_at":"2024-02-19T18:42:02.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T16:14:23.627Z","etag":null,"topics":["documentation","python","virtual-environment"],"latest_commit_sha":null,"homepage":"https://saadarazzaq.github.io/venvpy/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SaadARazzaq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-01T15:17:45.000Z","updated_at":"2024-03-01T14:04:07.000Z","dependencies_parsed_at":"2024-11-23T10:16:44.307Z","dependency_job_id":null,"html_url":"https://github.com/SaadARazzaq/venvpy","commit_stats":null,"previous_names":["saadarazzaq/venv.py","saadarazzaq/venvpy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaadARazzaq%2Fvenvpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaadARazzaq%2Fvenvpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaadARazzaq%2Fvenvpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaadARazzaq%2Fvenvpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaadARazzaq","download_url":"https://codeload.github.com/SaadARazzaq/venvpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243988956,"owners_count":20379649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation","python","virtual-environment"],"created_at":"2024-11-23T09:29:49.433Z","updated_at":"2025-03-17T06:45:10.951Z","avatar_url":"https://github.com/SaadARazzaq.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦Creating a Virtual Environment in Python\n\n![image](https://github.com/SaadARazzaq/venv.py/assets/123338307/8896dc55-5453-43a6-97ee-df4e3195cae7)\n\n**👉HIGHLY RECOMMEND VS Code FOR THE VIRTUAL ENVIRONMENT SETUP**\n\nA virtual environment is a self-contained Python environment that allows you to isolate and manage your Python dependencies for different projects. This is important when:\n\n- You need to install specific packages for a project, and they may conflict with packages required by other projects.\n- You want to share your project with someone else, and you want to ensure they have the exact same environment without worrying about package conflicts or version mismatches.\n\n\n## 🔗Why Use Virtual Environments?\n\n### Isolation of Dependencies 🔒\n\nIn Python, different projects often require different sets of packages and dependencies. Installing all packages globally can lead to conflicts and compatibility issues. Virtual environments provide a solution by allowing you to create isolated environments for each project.\n\nWith virtual environments, you can:\n\n- Install project-specific packages without affecting the global Python environment.\n- Keep dependencies separate, preventing conflicts between projects.\n- Easily switch between different project environments.\n\n### Reproducibility 🚀\n\nVirtual environments help ensure that your project remains reproducible. When you create a virtual environment and list the project's dependencies in a `requirements.txt` file, you can recreate the exact same environment on another machine or for a colleague.\n\nThis is especially useful when:\n\n- Sharing your code with others who may not have the same packages installed.\n- Collaborating on a project with team members who need consistent development environments.\n- Deploying your application to a server with a controlled environment.\n\n\n## ⚙️Creating Virtual Environments\n\nHere's how to create a virtual environment using the `python -m venv` command:\n\n- **Windows**: Open Command Prompt or PowerShell and run:\n```bash\npython -m venv myenv\n.\\myenv\\Scripts\\Activate\n```\n\n- **Linux and macOS**: Open a terminal and run:\n```bash\npython -m venv myenv\nsource myenv/bin/activate\n```\n\n\n## 🚪Deactivating the Virtual Environment\n\nTo deactivate the virtual environment and return to the global Python environment, run:\n```bash\ndeactivate\n```\n\nThis will deactivate the virtual environment and restore your Python environment to its default state.\n\n\n## Issues that might come\n\n\u003cimg width=\"532\" alt=\"image\" src=\"https://github.com/SaadARazzaq/venvpy/assets/123338307/be90c3b6-2b77-40aa-9a4c-05f7f9f49587\"\u003e\n\n If this issue comes then this means that you're encountering an issue with PowerShell's execution policy, which is preventing the activation script from running. PowerShell's execution policy is a security feature that controls the conditions under which PowerShell loads configuration files and runs scripts.\n\nTo resolve this issue, you can temporarily change the execution policy for the current PowerShell session to allow script execution. Here's how you can do it:\n\n- Open PowerShell as an administrator. Right-click on the PowerShell icon and select \"Run as administrator\".\n- Run the following command to temporarily set the execution policy to allow script execution:\n\n```bash\nSet-ExecutionPolicy RemoteSigned -Scope Process\n```\n\n- After changing the execution policy, try activating the virtual environment again using the activation script:\n\n```bash\n.\\myenv\\Scripts\\Activate\n```\n\nThis should allow you to activate the virtual environment without encountering the security error. Once you've finished working in the virtual environment, you can close the PowerShell session, and the temporary execution policy change will revert to the previous state.\n\nTo `permanently` set the execution policy for PowerShell, you'll need to run the Set-ExecutionPolicy command with appropriate parameters. Here's how you can do it:\n\n- Open PowerShell as an administrator. Right-click on the PowerShell icon and select \"Run as administrator\".\n- Run the following command to permanently set the execution policy to RemoteSigned for the current user:\n\n```bash\nSet-ExecutionPolicy RemoteSigned -Scope CurrentUser\n```\n\nThis command sets the execution policy to RemoteSigned for the current user only. It allows scripts that are downloaded from the internet to run if they are signed by a trusted publisher.\n\nIf you want to set the execution policy for all users on the computer, you can use the AllSigned policy, which requires all scripts to be signed by a trusted publisher. However, this may be more restrictive:\n\n```bash\nSet-ExecutionPolicy RemoteSigned -Scope LocalMachine\n```\n\n**Be cautious when setting the execution policy, especially to a less restrictive one like RemoteSigned, as it can pose security risks if you run untrusted scripts. Always ensure that you only execute scripts from trusted sources.**\n\n---\n\nNow you know how to create a virtual environment in Python on different operating systems and why it's important. Virtual environments are essential for managing dependencies, ensuring project isolation, and maintaining reproducibility in your Python projects. 😊\n\n```bash\nMade with 💖 by Saad\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadarazzaq%2Fvenvpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaadarazzaq%2Fvenvpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaadarazzaq%2Fvenvpy/lists"}