文章目录
  1. 1. PYTHONPATH

brew install zoidbergwill/python/
Or brew tap zoidbergwill/python and then brew install .
brew install python35
pyenv install –list

We don’t ever install to pip3, pyvenv, or python3, since we don’t know which Python version you want to use in general. Eventually I hope to add support for that somehow, though using pyenv might be a better solution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
brew install pyenv 
mvim .bash_profile
export PYENV_ROOT=/usr/local/opt/pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi #上面的内容将改变Pyenv root path并确保pyenv被初始化。注意:.bash_profile文件中,上面两个语句的顺序一定不能颠倒:(如果颠倒的话,pyenv global中的设置将会不起作用)
$SHELL -l
pyenv install --list
pyenv install 2.7.11
pyenv versions 查看当前可用的Python版本
pyenv version 查看当前使用的Python版本
pyenv global 查看当前的pyenv设置情况
pyenv shell
pyenv: no shell-specific version configured
pyenv shell中的Python版本设置只在当前的Shell会话中有效 通过设置Shell的PYENV_VERSION环境变量
pyenv shell中设置好Python版本后, 退出Terminal后,会自动还原为未设置的状态
pyenv local中设置的Python版本只对相应的当前目录有效 在目录中写入.python-version文件
pyenv global中设置的Python版本对所有的Shell全局有效,且退出后不会消失是通过设置/usr/local/opt/pyenv/version这个文件来实现的
pyenv shell system 设置Shell中重新使用系统中Python版本
pyenv shell --unset 取消Shell中的Python版本设置(恢复为默认状态)
pyenv local和pyenv shell命令都有--unset参数,而pyenv global命令没有--unset参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sets the global version of Python to be used in all shells 
by writing the version name to the ~/.pyenv/version file.
This version can be overridden by an application-specific .python-version
file, or by setting the PYENV_VERSION environment variable.
pyenv local

Sets a local application-specific Python version
by writing the version name to a .python-version file
in the current directory.
This version overrides the global version,
and can be overridden itself by setting the PYENV_VERSION
environment variable or with the pyenv shell command.
pyenv shell

Sets a shell-specific Python version
by setting the PYENV_VERSION environment variable in your shell.
This version overrides application-specific versions and the global version.
PYTHONPATH
1
2
# 报错Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x! ...
unset PYTHONPATH 可以解决, 检查PYTHONPATH路径
文章目录
  1. 1. PYTHONPATH