Mac new machine configuration python virtual environment notes

1. Mac new machine configuration Python virtual environment process

  1. Homebrew installation command: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" (by visual inspection, the download is relatively slow now, you can find a domestic mirror by yourself Connection)
  2. Install python3 environment: brew install python3
  3. Install a virtual environment: sudo pip3 install virtualenv
  4. Install the extension package for adding, deleting, modifying and checking the virtual environment: sudo pip3 install virtualenvwrapper
  5. Create a virtual environment directory: mkdir ~/.virtualenvs
  6. Find the path to python3 and virtualenvwrapper.sh: which python3 and which virtualenvwrapper.sh
  7. Open the global configuration file: open ~/.zshrc
    Configure the global configuration file:
    export WORKON_HOME=~/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source /usr/local/bin/virtualenvwrapper.sh source ~/.bash_profile
  8. Compile to make the configuration take effect: source ~/.zshrc
  9. Create a virtual environment: mkvirtualenv -p python3 xxx
  10. Open Pycharm and you can choose a virtual environment for development!

Reposted from: https://www.jianshu.com/p/6ffff1b6a590

2. Problems encountered

source ~/.zshrc
/Library/Developer/CommandLineTools/usr/bin/python3: 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=/usr/bin/python3 and that PATH is
set properly.

Solution

sudo pip3 install virtualenv virtualenvwrapper

Guess you like

Origin blog.csdn.net/gaogaonannannan/article/details/111223182