個人電腦上同時安裝了 Python 3.4 和 Python 3.7 兩個 Python 版本。如今打開終端窗口進入指定的版本。python
py -3.4 py -3.7
py -2.7
在終端窗口輸入 py -3.4 回車進入 Python 3.4 版本。Python 3.7 和 Python 2.7 同理。spa
同理,Python 3.7.5 和 Python 3.7.6 只需輸入 py -3.7.5 或 py -3.7.6 。code
使用不一樣版本的 pip 進行安裝。例如使用 Python 3.4 安裝 py2exe。blog
py -3.4 -m pip install py2exe
在 py 文件中指定使用的 Python 版本只需在文件開頭輸入。ip
#! python3.7 #! python3.4
或者修改文件 python.exe 的文件名。例如將 Python 3.7 版本的 python.exe 文件名改爲 python37.exe,Python 3.4 版本的改爲 python34.exe,其他的同理。pip
進入終端窗口輸入 python37 回車便可進入 Python 3.7 版本,輸入 python34 回車便可進入 Python 3.4 版本,其他版本同理。class
輸入 python34 -m pip install py2exe 使用 Python 3.4 安裝 py2exe 。變量
計算機屬性 --> 高級系統設置 --> 環境變量。配置
在用戶變量中打開 Path 變量,將各個 Python 版本的安裝路徑 以及 安裝路徑下的 scripts 文件夾路徑 添加進去,依次點擊肯定關閉所有窗口。終端