no module named ‘virtualenv’

In this tutorial, we will discuss the solutions on how to solve the No module named virtualenv which is encountered by python programmers.

The error ModuleNotFoundError: No module named ‘virtualenv’ occur because the python interpreter cannot find the installed virtualenv module in python library.

Time needed: 3 minutes

Here are the solutions to solve the error ModuleNotFoundError: No module named ‘virtualenv’ in windows, anaconda and Jupyter Notebook. In your project root directory open the command prompt and install the virtualenv package.

  • Solution 1: Installation of virtualenv in Python 2:

    The following command is to install the virtualenv in Python:

    pip install virtualenv

    install No module named virtualenv

    Install Pip in your Path environment variable:

    python -m pip install virtualenv

  • Solution 2: Installation of virtualenv in Python 3:

    The following command is to install virtualenv module in Python 3:

    pip3 install virtualenv

    This is the following command to install pip in your path environment variable:

    python3 -m pip install virtualenv

  • Solution 3: Install the server-side

    This is the following command to install if you get an error on your server-side:

    For Linux:
    sudo pip3 install virtualenv

    For Windows:
    pip install virtualenv --user

  • Solution 4: Installation of virtualenv module in py alias(windows)

    This is the following command to install virtualenv module in py alias(windows):

    py -m pip install virtualenv

  • Solution 5: Installation of virtualenv module in Anaconda

    This is the following command to install virtualenv module in Anaconda:

    conda install -c anaconda virtualenv

  • Solution 6: Installation of virtualenv module in Jupyter Notebook

    This is the following command to install virtualenv module in Jupyter Notebook:

    !pip install virtualenv

How to solve the No module named virtualenv?

To solve the error, we need to install the module by executing the command: pip install virtualenv.

The other common reason of error

  • It is either the spelling is incorrect or the capitalization of the module name.
  • Make sure to check the spelling name before installing the module.
  • Assured that the virtualenv module is installed correctly in the virtual environment.
  • The module is installed but it is installed at the incorrect path environment path.

If the error is continuous, check your Python version and ensure you are installing the module using the correct version of python.

Open your command prompt and then type the following command:

python --version
check the version python No module named virtualenv

Checked if the Module is Installed

To check if you have the virtualenv module installed by executing the command pip show virtualenv. It will either show the package is not installed or show a lot of information about the package you installed, which includes the location where the module is installed. For example name, version, summary, and location etc.

Conclusion

In conclusion, we already provide the solutions on how to solve the No module named virtualenv in windows platform, Jupyter Notebook and anaconda.

Leave a Comment