Fixing the error – ‘virtualenv’ is not recognized as an internal or external command, operable program or batch file

‘virtualenv’ is not recognized as an internal or external command, operable program or batch file is an error which occurs when you have a faulty virtualenv installation.

In the blog post I attempt to explain why this error takes place and how you can solve it, I will also add other solutions that could solve the error if possible.

Exploring the Error : ‘virtualenv’ is not recognized as an internal or external command, operable program or batch file

This is an error which occurs in python when you have a faulty virtualenv installation or when there is a compatibility problem..

You should avoid mixing between different errors. The error message should look like the error message bellow.

                                                                       #
'virtualenv' is not recognized as an internal or external command, operable program or batch file.
                                                                       #

Bellow is a number of tested solutions that I have tried and have worked for me.

Solution 1 : correctly install virtualenv using pip

Sometimes, when you try to install virtualenv the access gets denied as a result, the installation of virtualenv might become faulty which might result in errors in the future which are very similar to the error you have.

The solution is to use the following command to remove the faulty virtualenv installation.

                                                                       #
pip uninstall virtualenv
                                                                       #

Open cmd as administrator and run the following command.

                                                                       #
pip install virtualenv
                                                                       #

If the above does not work, try to force upgrade virtualenv using the command bellow.

                                                                       #
pip install --upgrade --force virtualenv
                                                                       #

If this solution does not work, please try the solution bellow.

Solution 2 : python -m venv <name of the virtual environment>

If none of the above has worked, you can try using the command bellow.

                                                                       #
python -m venv <name of the virtual environment>
                                                                       #

<name of the virtual environment> is clear and does not need explaining, I hope this has solved the issue, this is my last recommendation.

The solutions above should be enough to solve the problem, if you like our effort make sure to consider donating to our Kofi account, there is a red button that you can use if you are feeling generous.

Summing-up

I hope this article has helped you achieve your objective, If you like the effort we did here, please consider donating to our Kofi account located at the top of this page.

Keep coding, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/