K--
K--

Reputation: 734

ModuleNotFoundError: No module named 'virtualenvwrapper'

I'm trying to get virtualenvwrapper working in zsh (for Python 3, MacOS Apple Silicon) and haven't find a solution in other posts.

I'm running pip3 install virtualenvwrapper which appears successful.

Then I run mkvirtualenv helloworld and get this error:

(base) username@xxx ~ % mkvirtualenv helloworld         
created virtual environment CPython3.10.6.final.0-64 in 195ms
  creator CPython3Posix(dest=/Users/username/Users/username/.virtualenvs/helloworld, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/username/Library/Application Support/virtualenv)
    added seed packages: pip==23.0.1, setuptools==67.6.1, wheel==0.40.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
/Users/username/miniconda3/bin/python3: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')`

My entire .zshrc looks like this, as recommended by this answer https://stackoverflow.com/a/62993760 :

(base) username@xxx ~ % cat .zshrc                      

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/username/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/username/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/username/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export WORKON_HOME=~/Users/username/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=$(which virtualenv)
export VIRTUALENVWRAPPER_PYTHON="$(which python3)"
source $(which virtualenvwrapper.sh)

(I also use conda, and would ideally like both conda and virtualenvwrapper to work in this terminal.)

Upvotes: 0

Views: 125

Answers (2)

Qwerty Qazaq
Qwerty Qazaq

Reputation: 33

Try to install virtualenvwrapper through conda, such as

 conda install -c eumetsat virtualenvwrapper 

Upvotes: 0

codiander
codiander

Reputation: 53

There are multiple reasons for this kind of error and for solving this error make sure that you have installed the module, typed it correctly and take care of the casing as well as that can also be the reason of the error.

Upvotes: 2

Related Questions