1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 11a1c069abc5bee36915520973b453061837902f..c54a3532d50820bcd6238beee1abdcdf3911c2d4 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -413,5 +413,10 @@ function _autoswitch_startup() {
6 check_venv
7 }
8 9-autoload -Uz add-zsh-hook
10-add-zsh-hook precmd _autoswitch_startup
11+if ! type "python" > /dev/null; then
12+ printf "WARNING: python binary not found on PATH.\n"
13+ printf "zsh-autoswitch-virtualenv plugin will be disabled.\n"
14+else
15+ autoload -Uz add-zsh-hook
16+ add-zsh-hook precmd _autoswitch_startup
17+fi
18diff --git a/tests/test_plugin.zunit b/tests/test_plugin.zunit
19index 506a8cf7d0a00d8dc017bb8cfe39ce5c2e89047f..cb6cdd5cc8bb4153b00820a8351ea90ed4736bff 100644
20--- a/tests/test_plugin.zunit
21+++ b/tests/test_plugin.zunit
22@@ -12,6 +12,43 @@
23 LANG=".UTF-8"
24 }
2526+@test 'disabled if python not in path' {
27+ # Fake type failing on checking python
28+ function type {
29+ if [[ "$1" == "python" ]]; then
30+ return 1;
31+ fi
32+ }
33+
34+ # use run the first time to capture output
35+ run load ../autoswitch_virtualenv.plugin.zsh
36+
37+ assert "$lines[1]" same_as "WARNING: python binary not found on PATH."
38+ assert "$lines[2]" same_as "zsh-autoswitch-virtualenv plugin will be disabled."
39+
40+ # use load the next time to check its loaded into hooks correctly
41+ load ../autoswitch_virtualenv.plugin.zsh
42+
43+ assert '_autoswitch_startup' not_in $precmd_functions
44+}
45+
46+@test 'enabled correctly' {
47+ function type {
48+ return 0
49+ }
50+
51+ # use run the first time to capture output
52+ run load ../autoswitch_virtualenv.plugin.zsh
53+
54+ assert "$output" is_empty
55+
56+ # use load the next time to check its loaded into hooks correctly
57+ load ../autoswitch_virtualenv.plugin.zsh
58+
59+ assert $output is_empty
60+ assert '_autoswitch_startup' in $precmd_functions
61+}
62+
63 @test 'correct version exported' {
64 unset AUTOSWITCH_DEFAULTENV
65 load ../autoswitch_virtualenv.plugin.zsh