Building Initial Virtual Environment at Python - The first step you should do for Python Programming | ||
| ||
| Virtual environments are crucial in Python development because they isolate project dependencies, preventing conflicts and ensuring that each project uses the specific libraries and versions it requires. This allows developers to work on multiple projects with different requirements simultaneously without worrying about compatibility issues. Additionally, virtual environments simplify project sharing and deployment, as they package all necessary dependencies for a specific project, ensuring it runs correctly on different machines. Below are the steps to setup your Virtual Environment
STEP 1. Python Version Check To check if your system has Python installed, run this command in the command prompt:
On my Mac book, I needed to run as below if above does not work.
If Python is installed, you will get a result with the version number, like this
STEP 2. PIP Installation To check if your system has PIP installed, run this command in the command prompt:
If PIP is installed, you will get a result with the version number. For me, on a windows machine, the result looks like this:
If you do not have PIP installed, you can download and install it from this page: https://pypi.org/project/pip/
STEP 3. Building Virtual Environment It is suggested to have a dedicated virtual environment for each of the projects, and one way to manage a virtual environment is venv, which is included in Python. The name of the virtual environment is your choice; in this tutorial, we will call it Type the following in the command prompt, remembering to navigate to where you want to create your project: Windows:
Unix/MacOS:
This will set up a virtual environment, and create a folder named "myworld" with subfolders and files, like this:
Then you have to activate the environment by typing this command: Windows:
Unix/MacOS:
STEP 4. This is not something you shouldn't do on Mac environment (skip if you don't want) I prefer to call py instead of python for faster accessing just like windows, so what I do is making symbolic link. In order to do this, you should move to You can check python version like below:
Now you are all set! | ||
| | ||
| |