Problems and Solutions of Mac Installing virtualwrapper in python3 Environment

  • 2021-07-13 05:34:15
  • OfStack

Preface

I used mac to install virtualwrapper when encountered a problem, engaged in a long time, just get it done, here to summarize 1 under the sharing, for the same problem for friends to use, less detours.

Problem description:

The default system for Mac is python2, while I am using python3 installed by brew myself

The following are the problems that occurred during my installation

1. Install virtualwrapper

Open the terminal and enter the following command


pip3 install virtualenv
pip3 install virtualenvwrapper

2. Add code to the configuration file ~ /.bash_profile


# Settings for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

3. Make the configuration work:


source ~/.bash_profile

At this time, the following problems arise:


/usr/bin/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.

Cause analysis

From the sentence VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly in the error message, it is the environment that points to the path of python2, so we only need to modify this environment variable to the path of python3.

Solution

Open the configuration file vim ~/. bash_profile Add 1 line of code to the configuration file:


export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3

To make the configuration work:


source ~/.bash_profile

Try again, and make great achievements! ! !


Related articles: