Building Initial Virtual Environment at Python - The first step you should do for Python Programming

CK CK 3776 
Created at
Updated at  
559 0 0

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:

python --version

 

On my Mac book, I needed to run as below if above does not work.

python3 --version

 

If Python is installed, you will get a result with the version number, like this

Python 3.12.2

 

STEP 2. PIP Installation
To install any software, you must use a package manager like PIP, which is included in Python from version 3.4.

To check if your system has PIP installed, run this command in the command prompt:

pip --version

 

If PIP is installed, you will get a result with the version number.

For me, on a windows machine, the result looks like this:

pip 20.2.3 from c:\python39\lib\site-packages\pip (python 3.9)

 

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 myworld.

Type the following in the command prompt, remembering to navigate to where you want to create your project:

Windows:

py -m venv myworld

 

Unix/MacOS:

python -m venv myworld

 

This will set up a virtual environment, and create a folder named "myworld" with subfolders and files, like this:

% ls -Fal
total 16
drwxr-xr-x   7 chunkang  staff   224 Jul  2 14:39 ./
drwxr-x---+ 66 chunkang  staff  2112 Jul  2 14:29 ../
drwxr-xr-x  14 chunkang  staff   448 Jul  2 12:51 bin/
drwxr-xr-x   3 chunkang  staff    96 Jul  2 12:40 include/
drwxr-xr-x   3 chunkang  staff    96 Jul  2 12:40 lib/
-rw-r--r--   1 chunkang  staff   289 Jul  2 12:40 pyvenv.cfg

 

Then you have to activate the environment by typing this command:

Windows:

myworld\Scripts\activate.bat

 

Unix/MacOS:

source myworld/bin/activate

 

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 bin directory.

cd myworld/bin
ln -s python py

You can check python version like below:

py --version

 

Now you are all set!

Tags Initial Building Environment PIP Python Programming Python Virtual Environment Python venv venv Facebook X
Comments 0
Similar posts
  1. Run Python Code with Virtual Environment in PHP
    671
  2. Installing Python 3.8 in a venv environment on CentOS 7
    460
  3. A shell script that activates a Python virtual environment and then runs a specific Python script
    740
  4. PyTorch example to Forcast Stock Price based on 10 days Dataset
    651
  5. Beyond venv: Java's Project Isolation Strategy
    475
  6. Forecasting the Weather with PyTorch: A Beginner's Guide to Temperature Prediction
    1,427
  7. Getting Started with PyTorch: A Beginner's Guide to Building Your First Neural Network
    797
  1. Installing Python 3.8 in a venv environment on CentOS 7
    460
  2. CUDA versus OpenCL
    575
  3. Simple gRPC server based on Python
    392
  4. Python code to convert PDF file to Excel Spreadsheet
    692
  5. Python script to list files on your Google Drive and download one of them
    938
  6. Coinbase Python API - Basic Example
    461
  7. AWS Lambda Code Example based on Python
    333
  8. Python code using GPU on CentOS with AWS
    1,247
  9. Video Scence Detection with PySceneDetect
    2,318
  10. Python Audio Separation Libraries allowing you to isolate individual tracks
    1,430
  11. Python Version Control for Library Compatibility with pyenv - Downgrading/Upgrading Python Version
    900
  12. Deleting a specific user voice from the original audio track with Python
    546
  13. Creating an MR from the original MP3 audio in Python - Deleting Voice Track from Audio File
    436
  14. Creating mp3 audio file based on the text input with Python
    461
  15. Implementing Text To Speech / Audio with Python3 and pyttsx3
    353
  16. Python Simplified Assignment Operators
    533
  17. Trackback module used for Python Threading debugging
    839
  18. Python Flask with simple HTML files to server web pages along with API
    926
  19. Python Flask web server tutorial from the scratch
    618
  20. Simple Web Server based in Python
    366
  21. Thread Implementation in Python
    506
  22. A shell script that activates a Python virtual environment and then runs a specific Python script
    740
  23. Learning about Python Multiprocessing Technique
    590
  24. Simple Example to get the total number of records in BigQuery with Python
    665
  25. Using BigQuery in Python
    407
  26. Python Web Programming based on Django from the Scratch
    366
  27. Flink with Python: Core Concepts, Kafka Integration, and Architectural Trade-offs
    183
  28. How do I determine the client IP type in Python - IPv4 or IPv6
    758
  29. Predicting Buyer Preferences with PyTorch: A Deep Learning Approach
    1,228
  30. PyTorch example to Forcast Stock Price based on 10 days Dataset
    651
Recently updated
  1. Why SPF and DKIM Are Essential for Linux Email Servers?
    2
  2. How do I create animated background for Google Meet?
    19,014
  3. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    193
  4. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    75
  5. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    151
  6. Array of arguments passed to script in PHP
    83
  7. Invalid Auction Storms in Ad Tech
    91
  8. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    194
  9. The Two Clocks of Ad Server Architecture
    61
  10. Frequency Cap Architecture Overview
    505
  11. Collecting Proof-of-Play from 100,000 Screens
    139
  12. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    276
  13. What is RedisVL?
    102
  14. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    219
  15. TPU & GPU Cluster Management Tools
    229
  16. The Concept of Scaffolding in AI Agents
    217
  17. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    568
  18. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    246
  19. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    321
  20. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    196
  21. Machine Learning: Training vs. Ranking
    200
  22. The Continuous Learning Machine: Designing a Loop That Actually Turns
    212
  23. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    188
  24. Designing a Data Curation System Around a Vector Database
    212
  25. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    228
  26. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    646
  27. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    181
  28. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    203
  29. Understanding Data Lineage
    251
  30. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    159