折腾:
【已解决】Mac中pipenv install -r requirements.txt报错:UnicodeDecodeError ascii codec can’t decode byte 0xe8 in position ordinal not in range 128
期间,mac中已有python 3.7.3,希望安装另外一个3.5.2,为的是和某服务器中python 3.5.2一致。
mac中安装另外一个python3版本:3.5.2
mac python3 多环境安装
brew update brew install pyenv ➜ ~ which pyenv /usr/local/bin/pyenv ➜ ~ pyenv --version pyenv 1.2.11 echo 'eval "$(pyenv init -)"' >> ~/.bashrc source ~/.bashrc
结果:
~ which pyenv pyenv () { local command command="${1:-}" if [ "$#" -gt 0 ] then shift fi case "$command" in (rehash | shell) eval "$(pyenv "sh-$command" "$@")" ;; (*) command pyenv "$command" "$@" ;; esac }
即:
which pyenv
不对了。
所以再去去掉
~/.bashrc
最后的:
eval “$(pyenv init -)”
恢复正常:
➜ ~ which pyenv /usr/local/bin/pyenv
去看看list:
~ pyenv install --list Available versions: 2.1.3 2.2.3 2.3.7 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7-dev 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.15 2.7.16 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4-dev 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.4.10 3.5.0 3.5-dev 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.6.0 3.6-dev 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7-dev 3.7.1 3.7.2 3.7.3 3.8-dev activepython-2.7.14 activepython-3.5.4 activepython-3.6.0 anaconda-1.4.0 ... stackless-3.5.4
有:
3.5.2
然后去:
pyenv install 3.5.2
结果报错:
【已解决】mac中安装pyenv install 3.5.2报错:zipimport.ZipImportError can’t decompress data zlib not available
去看看:
➜ ~ pyenv --help Usage: pyenv <command> [<args>] Some useful pyenv commands are: commands List all available pyenv commands local Set or show the local application-specific Python version global Set or show the global Python version shell Set or show the shell-specific Python version install Install a Python version using python-build uninstall Uninstall a specific Python version rehash Rehash pyenv shims (run this after installing executables) version Show the current Python version and its origin versions List all Python versions available to pyenv which Display the full path to an executable whence List all Python versions that contain the given executable See `pyenv help <command>' for information on a specific command. For full documentation, see: https://github.com/pyenv/pyenv#readme
然后:
➜ ~ pyenv global system ➜ ~ pyenv local pyenv: no local version configured for this directory ➜ ~ pyenv shell pyenv: shell integration not enabled. Run `pyenv init' for instructions.
然后去设置当前环境:
➜ xxx git:(master) ✗ pyenv local 3.5.2 ➜ xxx git:(master) ✗ pyenv local 3.5.2
后来发现没用:
➜ xxx git:(master) ✗ which python /usr/bin/python ➜ xxx git:(master) ✗ which python3 /usr/local/bin/python3 ➜ xxx git:(master) ✗ python3 --version Python 3.7.3
python3还是之前的3.7.3,不是设置的3.5.2
算了,去
➜ xxx git:(master) ✗ pyenv shell 3.5.2 pyenv: shell integration not enabled. Run `pyenv init' for instructions.
结果好是:
并不能设置当前环境(shell)的python3是3.5.2
而只是,pyenv后续安装虚拟环境时,可以指定不同的版本,比如此处的3.5.2而已。
【总结】
brew update brew install pyenv
可以安装出来pyenv
然后去看看当前支持哪些版本:
pyenv install --list
有我要的:3.5.2
去安装:
pyenv install 3.5.2
但是发现:
用:
pyenv shell 3.5.2
或:
pyenv local 3.5.2
没法可以指定当前python 3为我要的3.5.2,还是之前安装好的3.7.3
而只是:
用pyenv新建虚拟环境时,可以指定python3是3.5.2
也许是自己目前没研究透。有机会再说。
转载请注明:在路上 » 【部分解决】mac中安装python3的多个不同版本