mkvirtualenv Verified current stable Not installed? Package Management

Mkvirtualenv / Create Virtualenv Specific Python

Create Virtualenv Specific Python

Command to create a virtual environment with a specific Python interpreter.

$
Terminal
mkvirtualenv --python </usr/local/bin/python3.8> <virtualenv_name>

When To Use

During development when a specific version of Python is required for compatibility with existing codebases.

Pro Tip

Verify the target Python version exists with `which python3.8` before executing; otherwise, it will default to system Python.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
mkvirtualenv --python </usr/local/bin/python3.8> <virtualenv_name>

Anatomy of Output

Understanding the result

Creating virtual environment with /usr/local/bin/python3.8 Creation Confirmation

Indicates the specific Python version being used.

Your requirements.txt file was parsed successfully Requirement Info

Confirms successful reading of the requirements file.

Warning: environment based on 'python' Notice

Ensure this does not affect compatibility.

Power User Variants

Optimized versions

mkvirtualenv --no-site-packages --python /usr/local/bin/python3.8 myenv

Isolates from global packages during creation.

mkvirtualenv --upgrade-interpreter myenv

Upgrades the interpreter to the latest available version in that series.

Troubleshooting

Common pitfalls

Error: Specified Python interpreter does not exist

Solution: Ensure the interpreter path is correct or install the specific Python version.

Error while creating virtualenv

Solution: Check dependencies like pip and setuptools; install if missing.

Error: Invalid environment name

Solution: Environment names must adhere to valid naming conventions.

Command Breakdown

What each part is doing

mkvirtualenv
Base Command
The executable that performs this operation. Here it runs Mkvirtualenv before the shell applies any redirect operators.
</usr/local/bin/python3.8>
usr local bin python3.8
The value supplied for usr local bin python3.8.
<virtualenv_name>
virtualenv name
The value supplied for virtualenv name.
--python
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative package management tools for the same job.