What are the Reasons for the ‘zsh: command not found: virtualenv’
There are multiple reasons for the ‘zsh: command not found:virtualenv’ error in macOS, which are given below:
1: Missing Virtualenv Installation on Zsh
The ‘zsh: command not found: virtualenv’ error can occur because of a missing Virtualenv installation on your Mac system.
2: Virtualenv Not in PATH
The PATH environment variable is a crucial factor that could become a reason for generating the command not found error. If your Virtualenv executable directory is not present in the system’s PATH environment variable, you will experience the error.
How to Fix ‘zsh: command not found: virtualenv’ on Mac
To fix the ‘zsh: command not found:virtualenv’ issue, the only way to do this is to install Virtualenv on your Mac system.
Install Virtualenv on Mac
The easiest way to install Virtualenv on Mac is through the Python Package Manager called (pip). You should open the Zsh shell and run the following command to install Virtualenv on macOS.
In most cases, after performing this step, the error will be resolved. As in my case, after installing Virtualenv through pip, I immediately run the following command to ensure no error occurs now.
If you still getting the ‘zsh: command not found: virtualenv’, you can try uninstalling it first from the system using the following command:
Then reinstalling it again with sudo privileges.
The ‘zsh: command not found: virtualenv’ error in Virtualenv can be frustrating, but you can resolve it easily by installing the Virtualenv on your macOS from the pip install command. Once, you managed to install it on your system, there is hardly any chance of error occurring after that. If you still encounter an error, you can try installing it with sudo privileges to fix the issue and effectively manage virtual environments for your Python projects.