Home Backend Development Python Tutorial Windows下实现Python2和Python3两个版共存的方法

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

Jun 10, 2016 pm 03:10 PM
python2 python3 windows

一直用的是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! 

还是挺方便的。
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files Jun 12, 2024 pm 02:46 PM

What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files

Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS Aug 26, 2024 am 10:07 AM

Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS

How to turn off Security Center in Windows 11 How to turn off Security Center in Windows 11 Mar 28, 2024 am 10:21 AM

How to turn off Security Center in Windows 11

Windows 10 vs. Windows 11 performance comparison: Which one is better? Windows 10 vs. Windows 11 performance comparison: Which one is better? Mar 28, 2024 am 09:00 AM

Windows 10 vs. Windows 11 performance comparison: Which one is better?

How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated? How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated? Feb 21, 2025 pm 10:54 PM

How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated?

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node?

See all articles