Python2和python3的IDLE命令行添加到桌面

在电脑上安装了Python2.7和Python3.8,都是通过下载www.python.org中的安装文件安装完成的。

Win10系统,Thinkpad E480笔记本电脑。

安装完成,仅有各自目录下的

D:\python27\

D:\python3\python38\

各自目录下都有一个python.exe和pythonw.exe。

安装完后,在环境变量path中已经有

D:\python3\python38\和D:\python3\python38\Scripts。

手动把D:\python27\和D:\python27\Sripts也添加了进去。

在命令行执行Python -V时,是3.8.0版本。

上网搜了搜,有方法是把可执行文件的名字给改掉。有点不爽。

找了找IDLE命令行的命令,发现是在libs\idlelib\下的IDLE.bat来实现的。

python27的idle.bat

@echo off

rem Working IDLE bat for Windows - uses start instead of absolute pathname

start idle.pyw %1 %2 %3 %4 %5 %6 %7 %8 %9

意思是关闭回显,注释,启动同目录下的idle.pyw,双击idle.bat,没有反应。

同样看了看python38的idle.bat

@echo off

rem Start IDLE using the appropriate Python interpreter

set CURRDIR=%~dp0

start "IDLE" "%CURRDIR%..\..\pythonw.exe" "%CURRDIR%idle.pyw" %1 %2 %3 %4 %5 %6 %7 %8 %9

意识是关闭回显,注释,设置CURRDIR变量,启动pythonw.exe来执行idle.pyw。

双击idle.bat,可以出现python 3.8.0的IDLE命令行。

python2.7的IDLE不能执行,估计是path的顺序问题导致的,调用的是python3.8的可执行文件。

想是否可以用python3.8的idle.bat代替python2.7的idle.bat。

拷贝start "IDLE" "%CURRDIR%..\..\pythonw.exe" "%CURRDIR%idle.pyw" %1 %2 %3 %4 %5 %6 %7 %8 %9到python2.7的IDLE,真的可以执行。

把各自的IDLE.bat添加到桌面快捷方式,就解决了。

猜你喜欢

转载自www.cnblogs.com/darkshitlord/p/12060192.html