pyenv: no such command `virtualenv-init'

8 min read

The error message "pyenv: no such command `virtualenv-init'" means that the pyenv command cannot find the virtualenv-init command.

This error typically occurs when the virtualenv plugin is not installed or not properly set up in your pyenv environment.

To resolve this issue, you need to install the virtualenv plugin for pyenv. Here are the steps:

  1. Check if the virtualenv plugin is already installed by running the following command:

    pyenv virtualenv-init
    

    If you get an error "pyenv: no such command `virtualenv-init'", it means the plugin is not installed.

  2. Install the virtualenv plugin using the pyenv-installer. Open a terminal and run the following command:

    curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
    

    This command will download and run the pyenv-installer script, which will install the necessary files and setup the virtualenv plugin.

  3. Once the installation is complete, restart your terminal or open a new terminal window to load the updated environment.

  4. Verify that the virtualenv plugin is working by running the following command:

    pyenv virtualenv-init
    

    You should see some shell code output.

After completing these steps, you should no longer see the "pyenv: no such command 'virtualenv-init'" error. You can now use the virtualenv and pyenv commands together to manage your Python environment.