Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem while installing virtualenvwrapper with pyenv + pipx

I'm trying to install virtualenvwrapper (not pyenv-virtualenvwrapper) in my macOS (using zsh). I'm using pyenv to mange multiple python versions and pipx to install CLI stuff.

I'm using Python 3.8.1

$ pyenv versions
  system
  2.7.17
* 3.8.1 (set by /Users/my_user/.pyenv/version)

I installed virtualenvwrapper with pipx

$ pipx install virtualenvwrapper

$ pipx list
venvs are in /Users/my_user/.local/pipx/venvs
apps are exposed on your $PATH at /Users/my_user/.local/bin
   package sshuttle 0.78.5, Python 3.8.1
    - sshuttle
   package virtualenv 20.0.15, Python 3.8.1
    - virtualenv
   package virtualenvwrapper 4.8.4, Python 3.8.1
    - virtualenvwrapper.sh
    - virtualenvwrapper_lazy.sh

and I inserted in my .zshrc the following lines:

export WORKON_HOME=$HOME/.virtualenvs
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME

But when I launch the shell I get the following error:

/Users/my_user/.pyenv/versions/3.8.1/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: 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=/Users/my_user/.pyenv/shims/python and that PATH is
set properly.
$

How can I fix this problem?

like image 225
floatingpurr Avatar asked Mar 02 '23 15:03

floatingpurr


1 Answers

Fixed specifying a specific VIRTUALENVWRAPPER_PYTHON without pointing to the shim

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/python3.8
source /Users/my_user/.local/pipx/venvs/virtualenvwrapper/bin/virtualenvwrapper.sh
like image 58
floatingpurr Avatar answered Apr 08 '23 14:04

floatingpurr