It needs to be used in both python2 and python3 environments, or different packages need to be installed in different projects.
we hope that the packages installed between different projects do not interfere with each other, and then you can configure the virtual environment of Python using pyenv.
installation pyenv
1 | export PATH="~/.pyenv/bin:$PATH" |
按照官方文档配置即可,mac zsh 用户,将 以上三句放入到 .zshrc 即可。
see available versions
1 | pyenv install -l |
install python in virtual env
install python 2.7.14
1 | pyenv install 2.7.14 |
install python 3.6.3
1 | pyenv install 3.6.3 |
solve macOS High Sierra: ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
1
2
3
4
5
6
7
8
9
10
11 # about zlib
export CFLAGS="-I$(xcrun --show-sdk-path)/usr/include"
# about readline
export CFLAGS="-I$(brew --prefix readline)/include $CFLAGS"
export LDFLAGS="-L$(brew --prefix readline)/lib $LDFLAGS"
# about openssl
export CFLAGS="-I$(brew --prefix openssl)/include $CFLAGS"
export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"
# about SQLite (maybe not necessary)
export CFLAGS="-I$(brew --prefix sqlite)/include $CFLAGS"
export LDFLAGS="-L$(brew --prefix sqlite)/lib $LDFLAGS"
Set or show the global Python version
1 | $ pyenv global 3.6.3 or system |
system stands for this mac
show list all Python versions available to pyenv
1 | $ pyenv versions |
create virtual env
create current 3.6.3 version python
virtual env
1 | $ pyenv virtualenv vpy3 |
vpy3 is this virtual env alias
pyenv activate & deactivate
1 | $ pyenv activate vpy3 |
这是时候就可以开始pip安装依赖包了
1 | ➜ pyenv activate vpy3 |
Checking if Disqus is accessible...