Windows下实现Python2和Python3两个版共存的方法

WBOY
Release: 2016-06-10 15:10:35
Original
1011 people have browsed it

一直用的是python2,从python 2.3到python 2.7.6, 出于想了解python3的新特性,又安装了python3.3.3. 用了才发现蛮方便的。python的各个版本是独立共存的,不相互冲突的。下面说下如何操作:

1. 独自安装好python2.7.6 和 python3.3.3
2. 修改注册表:   打开->regedit
HKEY_CLASSES_ROOT\Python.File\shell\open\command的默认值 
修改为"C:\Python27\python.exe" "%1" %*(C:\Python27是我的Python2.7安装路径), 
同时将C:\Python27\和C:\Python27\Scripts\添加到环境变量中。

3.在C:\Python27\中新建一个python33.bat的文件,并运行这个文件

复制代码 代码如下:

@ echo off 
C:\Python33\python.exe %* 

效果:
如果我想用python2.7.6的时候就输入 python27,想用python3.3.3的时候,就输入python33
复制代码 代码如下:

D:\Python>python27 2to3Test.py 
Hello,World! 
 
D:\Python>python33 2to3Test.py 
Hello,World! 

还是挺方便的。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!