

If you are using python3, you can use pip3 instead of pip in the above command., Setup and Use Virtualenv in Linux If can also use python’s PIP to install virtualenv using the following command. If you want to install python virtualenv using the easy_install package installer, you can use the following command. To install virtualenv using the apt package management system, you can use the following command. There are a number of ways to install virtualenv on your system. If virtualenv is not installed on your system, you can install it in Linux using the commands discusses in the following section Install Virtualenv in Linux Ubuntu virtualenv -versionĪfter execution of the above command, If you see a version number (in my case 1.6.1), it’s already installed on your system. To check if it’s already installed run the following command in your terminal. There is a chance that python virtualenv is already installed on your system. By using virtual environments, you can keep your projects isolated and avoid version conflicts.Install virtualenv and Verify the Installation

When you’re done working in the virtual environment, you can deactivate it by running the following command in the terminal: deactivateĪnd that’s it! You have successfully installed Python 3.6 with a virtual environment on Ubuntu 22.04. You should see the name of the virtual environment in the terminal prompt, indicating that the virtual environment is active: (myenv) 8: Deactivate the Virtual Environment To activate the virtual environment, run the following command in the terminal: source myenv/bin/activate This will create a virtual environment named “myenv” in the current directory. Then, run the following command: python3.6 -m venv myenv

In the terminal, navigate to the directory where you want to create the virtual environment. Now that we have Python 3.6 installed, let’s create a virtual environment for our project. You should see the following output: Python 3.6.x To check the installed Python version, run the following command in the terminal: python3.6 -version Make -j$(nproc) # nproc will give you the CPU cores configure -enable-optimizations -with-lto -with-pydebug Step 4: Compile Python Source cd Python-3.6.15 Libgdbm-dev libnss3-dev libedit-dev libc6-dev Libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \ Libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ Step 2: Prerequisites sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ Run the following command in the terminal: sudo apt update We will show you how to install Python 3.6 on Ubuntu 22.04 and set up a virtual environment using the built-in venv module.īefore installing anything new, it’s always a good idea to update the package index. As a programmer, having multiple Python versions and creating an isolated virtual environment for your projects can be extremely useful.
