Using Python 3 in virtualenv

Here is an example of how you can use Python 3 in a virtual environment using the virtualenv package:

# First, install virtualenv
pip install virtualenv

# Create a new virtual environment with Python 3
virtualenv -p python3 myenv

# Activate the virtual environment
source myenv/bin/activate

# Your command prompt should now be prefixed with (myenv) to indicate that you are in a virtual environment

# Now, you can install packages and run Python 3 code in this environment
pip install numpy
python myscript.py

# When you are done working in the virtual environment, you can deactivate it
deactivate

Watch a course Python - The Practical Guide

This will create a folder called myenv in your working directory where all the dependencies and python executable will be installed. You can name it whatever you want. Also, you can use python3 instead of python when activating and deactivating the virtual environment in case you have multiple python versions installed in your system.