Oct 24, 2023 4 min read

How to Fix “mkvirtualenv: command not found” in Bash?

Fix the “mkvirtualenv: command not found” error in bash with our step-by-step tutorial. It is the default command-line interpreter/shell for OS.

Fix “mkvirtualenv: command not found” in Bash
Table of Contents


Before we start talking about how to fix “mkvirtualenv: command not found” in Bash, let's briefly understand-What is Bash ?

Bash, short for "Bourne Again Shell," is the default command-line interpreter or shell for most Unix-based operating systems, including Linux and macOS. It is a powerful and highly flexible shell that allows users to interact with the operating system through commands and scripts.

When working with virtual environments using tools like virtualenvwrapper, you may encounter the error message "mkvirtualenv: command not found" in Bash. This typically happens when the necessary environment variables and configurations are not properly set up.

This tutorial will provide steps to fix this error and ensure the mkvirtualenv command is recognized by your Bash shell. We will also address a few FAQs on how to fix “mkvirtualenv: command not found” in Bash.

Reason 1: Virtual Environment is Not Set

The virtual environment is not configured in the system, which results in the error "mkvirtualenv: command not found". Because the packages "virtualenv" and "virtualenvwrapper" are missing.

Reason 2: The command "mkvirtualenv" is not installed.

The mkdirvitualenv command not being present in the operating system could also be the cause of the mkvirtualenv: command not found error. The error is demonstrated in the figure below.

mkvirtualenv test

This tutorial will walk you through installing the mkvirtualenv command and configuring a virtual environment on Linux.

Solution: Install the “mkvirtualenv” Command and Configure the Virtual Environment

Following are the detailed instructions for installing the mkvirtualenv tool and configuring the virtual environment on Linux.

Step 1: Install Build Essential for Python

Use the following command to first install the build-essential packages for the Python module:

sudo apt install python3-pip build-essential     

sudo yum install python3-pip gcc-c++ groupinstall "Development Tools" 
sudo pacman -Sy python3-pip base-devel         

Now dependencies are installed, i.e. python & build-essential.

Step 2: Install virtualenv and virtualenvwrapper

The Python package virtualenv enables the user to build several environments. While the virtualenvwrapper is a group of predefined shell functions like bash, ksh, and zsh. Using the pip command, install both of the Python packages as follows:

sudo pip install virtualenv virtualenvwrapper

The virtualenv and virtualenvwrapper packages have been set up.

Step 3: Search the File Path (virtualenvwrapper.sh)

The following step entails looking up the location of the virtualenvwrapper.sh file (which includes the execution of shell functions) file using the find command:

sudo find / -iname virtualenvwrapper.sh

The location of the virtualenvwrapper.sh file is displayed.

Note: The trust boundaries established by the Gnome Virtual are the cause of the permission being denied for the error.

(GVFS) File System. This file cannot even be accessed by the sudo user.

Step 4: Configure the .bashrc File

The ".bashrc" file should now be configured to create the virtual environment. To accomplish this, export the following variable and source command with the virtualenvwrapper.sh file path, as displayed:

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=~/.env
source /usr/local/bin/virtualenvwrapper.sh

Exit after saving the .bashrc file.

Step 5: Execute the Bash File

To view the new modifications, run the source command after applying the .bashrc file:

source ~/.bashrc

The virtual environment can be created using the virtualenvwrapper now.

Verify Results

The environment for the mkvirtalenv command is already configured, and the user can check the command's version here:

mkvirtualenv --version

Now we can use mkvirtualenv.

Creating the Virtual Environment

Let's build a virtual environment in the terminal:

mkvirtualenv test

The "test" virtual environment is established.

FAQs on Fixing "mkvirtualenv: command not found" in Bash

What is virtualenvwrapper? 

virtualenvwrapper is a handy tool that helps create and manage Python virtual environments. It provides shortcuts and additional functionalities to streamline virtual environment management.

Why does the "command not found" error occur with mkvirtualenv? 

The "command not found" error occurs when the mkvirtualenv command is not recognized by Bash. It is usually caused by missing or incorrect environment variable configurations related to virtualenvwrapper.

How can I install virtualenvwrapper? 

To install virtualenvwrapper, you can use the Python package manager pip. Run the command pip install virtualenvwrapper to install it in your Python environment.

What is the purpose of the WORKON_HOME environment variable?

The WORKON_HOME environment variable specifies the directory where your virtual environments will be stored. It is used by virtualenvwrapper to create and manage the virtual environments.

What is the purpose of the source command in Bash? 

The source command in Bash is used to execute commands in the context of the current shell. It is commonly used to reload environment variable configurations or execute scripts within the current shell session.

How does virtualenvwrapper find the mkvirtualenv command? 

virtualenvwrapper relies on the availability of the WORKON_HOME environment variable, which specifies the virtual environments directory. It locates the mkvirtualenv command in that directory.

After making changes to my Bash configuration file, do I need to restart the shell? 

Yes, after making changes to your Bash configuration file, it is necessary to restart your shell or run the source command on the file to reload the configurations.


The virtual environment must be established or the command "mkvirtaulenv" must be installed for the error "mkvirtualenv: command not found" to occur. Install the virtual environment settings for Python by installing the virtualenv, virtualenvwrapper, and build-essential packages. The ".bashrc" file should then be adjusted for the virtual environment. Use the source command to run ".bashrc" and the "mkvirtualenv" command to set up a virtual environment.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.