How to Install Python 3 PIP and Virtualenv for a Data Scientist Environment


Thank you for visiting this tutorial. Iโve personally crafted every aspect of this blog, and Iโm delighted to share with you what Iโve learned about AI. ๐
In this section, Iโll guide you through the best practices for installing and setting up a Python development environment. Installing Python can sometimes be tricky, especially when deciding between Python 2.7 and Python 3+. Iโll also explain how virtual environments (venv) work and demystify the meaning of PEP (Python Enhancement Proposal). ๐๐ป
So, sit back, relax โ, and letโs dive in !
1. Getting Started with Python
To start our journey, Iโve signed up for several Python courses designed with data scientists in mind. ๐ These courses cover everything from the fundamentals of Python programming to advanced topics such as data manipulation, analysis, and developing machine learning models.
By completing these courses, weโll build a strong Python foundation, empowering us to tackle sophisticated projects like constructing LLMs confidently. ๐
We will use Jupyter and VSCode, and you can find all the source code on my GitHub repository. ๐ป
2. Python introduction
๐ค What is the version of Python?
๐ก We have two options: Python 2.7 and Python 3+. Spoiler alert: Python 2.7 is not compatible with the latest Python versions (specifically version 3 and higher), and Python 3+ does not maintain backward compatibility with older versions. Therefore, for our purposes, we will exclusively use Python version 3 or higher throughout this blog.
๐ค What is PEP?
๐ก PEP stands for Python Enhancement Proposal. Itโs a document that provides information for Python developers or explains new features for Python. PEPs offer technical specifications for Python, making them easy to understand and implement in coding practices.
๐ค What is pip?
๐ก pip is the package installer for Python. It allows you to easily install and manage Python packages from the Python Package Index (PyPI). Whether youโre adding libraries for data analysis, web development frameworks, or tools for machine learning, pip simplifies the process by handling dependencies and ensuring packages are installed in your Python environment. Itโs an essential tool for Python developers to extend the functionality of their projects efficiently.
๐ค What is venv?
๐ก venv is a Python module used to create virtual environments. Each environment can independently manage its own Python package versions within its directory. Itโs a straightforward tool that ensures clean and isolated environments for different projects.
Easy peasy lemon squeezy!ย ๐
3. Installation
Now, letโs dive into setting up our Python environment โย itโs code time!ย ๐๐จโ๐ป๐ฉโ๐ป
Linux
For the Linux environment, please note that the code below has been verified onย Ubuntu. Make sure to verify your operating system version and adapt the commands accordingly โจ.
$ python3 --version
Python <strong>3.11.6</strong> #version 3.X.Y (3.11.6 on my linux machine)
JavaScript- Check Python local version (if installed)
If theย Pythonย command is not found, youโll need to install Python ๐.
- Installation Python 3 or higher
<code>$ sudo apt-get update
$ sudo apt-get install python3
</code>
JavaScriptAfter updating and installingย Python 3, now you need to check if Python 3 has been installed correctly โ
<code>$ python3 --version
Python 3.11.6 # version 3.X.Y (3.11.6 on my linux machine)
</code>
JavaScriptIf the version of Python is displayed, it means Python is installed and available in your terminal context.
Happy coding !ย Letโs move on to the next step. ๐
- Use Python 3 and print โHello, World!โ :
<code>$ python3
Python 3.11.6 (main, Oct 8 2023, 05:06:43) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello, World!') # print hello world on your terminal
Hello, World!
</code>
JavaScriptCongratulations on your first โHello, World!โ in Python! ๐๐ Keep up the great work!
- Install virtualenv (Recommanded)
Firstly, you should install pip ๐ ๏ธ, This command will update your package index and then install pip for Python 3 on your system.
<code>$ sudo apt update<br>$ sudo apt install python3-pip<br></code>
JavaScriptCheck if pip installed correctly by running the following command: ๐ป๐
<code>$ pip3 --version<br>pip 24.0 from $HOME/.local/lib/python3.11/site-packages/pip (python 3.11)<br></code>
JavaScriptCool ๐! To install and use virtualenv in Python, you just need two command lines. Hereโs how to update and initialize a virtual environment (venv):
These commands first install virtualenv using pip and then initialize a virtual environment named .venv in the current directory.
<code>python3 -m pip install --user virtualenv<br>python3 -m venv .venv # init .venv on current directory<br></code>
JavaScriptWohooo, congratulations! ๐ Youโre now on the latest step.
Youโve installed Python 3 and initialized a virtual environment (venv). Just so you know, venv creates all necessary data and imports Python libraries into the current directory.
Letโs take a look at the .venv directory ๐.
$ tree .venv
.venv
โโโ bin
โ โโโ activate
โ โโโ activate.csh
โ โโโ activate.fish
โ โโโ Activate.ps1
โ โโโ pip
โ โโโ pip3
โ โโโ pip3.11
โ โโโ python -> python3
โ โโโ python3 -> /usr/bin/python3
โ โโโ python3.11 -> python3
โโโ include
... More files
JavaScript๐๏ธ Windows ๐๏ธ
๐๏ธ MAC OS ๐๏ธ
Conslusion
Now that Python is installed, itโs time to kick off your project and dive into coding with Python 3! ๐
This language is beloved by many for its straightforward syntax and wide range of applications. Whether youโre just starting out or youโre a seasoned pro, Python 3 is perfect for everything from building web apps and automating tasks to crunching data and creating machine learning models.
So, roll up your sleeves, fire up your IDE, and letโs bring your ideas to life with Python! ๐ป๐
Thank You for Reading this Blog and See You Soon! ๐ ๐
Let's connect ๐
Latest Blogs
Read My Latest Blogs about AI

Inside OpenAIโs Custom Chip Leap: The Broadcom Deal, 10GW of Compute, and Its Implications for AI
OpenAI and Broadcom announce a partnership to develop 10GW of custom AI chips starting in 2026. Discover how this reshapes costs, performance, and supply for AI infrastructure.
Read more