Error message 'mkvirtualenv is not recognized as an internal or external command'

Viewed 26899

While I was trying to execute the mkvirtualenv command on the command prompt, I was getting this error:

C:\Users\mukesh>mkvirtualenv myproject 
'mkvirtualenv' is not recognized as an internal or external command, operable program or batch file.
3 Answers

For Python 3.3 or newer, Commands for installing, creating and activate virtual environment has been changed.

You can install virtual environment using pip:

py -m pip install --user virtualenv

For creating new environment:

py -m venv myproject

To activate your virtual environment:

.\myproject\Scripts\activate

After activating virtual environment, You’ll see “(myproject)” next to the command prompt.

You may find this link useful, as it shows the steps required. It is possible you have simply missed the earlier steps, leading to the error.

The below information is from: https://docs.djangoproject.com/en/2.2/howto/windows/

This will run you through the creation of a virtual environment on Windows:

Install virtualenv and virtualenvwrapper¶

virtualenv and virtualenvwrapper provide a dedicated environment for each Django project you create. While not mandatory, this is considered a best practice and will save you time in the future when you’re ready to deploy your project. Simply type:

pip install virtualenvwrapper-win

Then create a virtual environment for your project:

mkvirtualenv myproject

The virtual environment will be activated automatically, and you’ll see “(myproject)” next to the command prompt to designate that. If you start a new command prompt, you’ll need to activate the environment again using:

workon myproject

To create a virtual environment,

decide upon a directory where you want to place it, and run the venv module as a script with the directory path:

python3 -m venv tutorial-env

This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter and various supporting files.

A common directory location for a virtual environment is .venv. This name keeps the directory typically hidden in your shell and thus out of the way while giving it a name that explains why the directory exists. It also prevents clashing with .env environment variable definition files that some tooling supports.

Once you’ve created a virtual environment, you may activate it.

On Windows, run:

tutorial-env\Scripts\activate.bat

On Unix or MacOS, run:

source tutorial-env/bin/activate

Related