1

I installed virtualenv and virtualenvwrapper. However, when entering mkvirtualenv followed by the name of the environment I'm looking to create, I'm getting the following error:

@Laura-Macbook ~ % mkvirtualenv myapp 
zsh: command not found: mkvirtualenv

And when I run virtualenvwrapper.sh:

@Laura-Macbook ~ % virtualenvwrapper.sh
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.

My ~/.zshrc profile is as follows:

__conda_setup="$('/Users/ct/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/ct/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/ct/opt/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/ct/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

alias python=/usr/local/bin/python3
alias pip=/usr/local/bin/pip3

# Add Homebrew's executable directory to the front of the PATH
export PATH=/Users/ct/Library/Python/3.8/bin:$PATH
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

I've tried to follow instructions on several posts but don't seem to be able to solve it! I installed python and pyenv following these instructions.

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Laura Kebab
  • 29
  • 1
  • 5
  • you said you get error when you run `mkvirtualenv` - but you doesn't run `mkvirtualenv` but `virtualenvwrapper.sh`. You run wrong command. – furas Jul 11 '21 at 18:14
  • Yes but I get the error in subject when I run `mkvirtualenv`. I ran `virtualenvwrapper.sh` to see where it was located as it seems to be part of the issue... Here is what I get with `mkvirtualenv`: `@Laura-Macbook ~ % mkvirtualenv myapp zsh: command not found: mkvirtualenv` I clarified in the message – Laura Kebab Jul 11 '21 at 18:17
  • The easiest way to have this error is not to have installed `virtualenvwrapper` -- or at least, not to have installed it _for the specific Python installation you're trying to use it with_. How did you install it? If you installed it with `pip`, do you know which Python installation that copy of `pip` was linked to? Using, say, a Macports-provided copy of pip to install `virtualenvwrapper` won't make it available for the Apple-provided Python interpreter (which you're using here). – Charles Duffy Jul 11 '21 at 18:43
  • @CharlesDuffy - does this answer your question? `@Laura-Macbook ~ % which pip3 /Users/ct/Library/Python/3.8/bin/pip3` – Laura Kebab Jul 11 '21 at 19:05
  • Okay, so that's a Python 3.8 `pip3`, vs a Python 2.7 that `virtualenvwrapper.sh` tries to use. If that's the `pip3` you used to install `virtualenvwrapper`... well, that mismatch does explain the issue. – Charles Duffy Jul 11 '21 at 19:11
  • @CharlesDuffy - that makes sense. Could you tell me what I should do then? I'm a beginner trying to create my first virtual environment – Laura Kebab Jul 11 '21 at 19:22
  • Personally, I don't use `virtualenvwrapper` and haven't ever seen a need for it; the basic `virtualenv` tool works pretty well. Does `python3 -m virtualenv --help` give you usage instructions? (If not, does `pip3` tell you virtualenv is installed, and if not, does installing virtualenv with pip3 make the above work?) – Charles Duffy Jul 11 '21 at 19:32
  • Ok - I managed to create it with `virtualenv`. Thanks for all your help! – Laura Kebab Jul 11 '21 at 19:41

0 Answers0