Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use both Python2 and Python3

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to use Python2 and Python3 at the same time", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use Python2 and Python3 at the same time.

I. installation

1. Python2.x and Python3.x versions can be downloaded from the official website or the Python tribe. Just pay attention to the system.

2. Install Python2.x and Python3.x into different folders. For example, under Windows, D:\ Program Files\ Python2 and D:\ Program Files\ Python3

3. Add the installation path of Python2 and Python3 and the path of the next level\ Scripts folder to the environment variable.

How to use Python2 and Python3 at the same time?

Method 1: configure environment variables

By changing the location order of the system environment variables Python2.7 and python3.5 so that the temporary version is needed first, enter python in the cmd command window, and the default is to configure the previous version.

(1) Open Advanced system Settings:

(2) Open Advanced-> PATH

(3) enter the value of the variable and enter the address where you installed python3 and python2 (note that the semicolon is separated;)

For example, mine is python3.5 at D:\ Program Files\ python3.5;D:\ Program Files\ python3.5\ Scripts

Python2.7 is located at C:\ Python27;C:\ Python27\ Scripts

(4) Open cmd, and enter python to be the python3.5 in the first location of the environment variable.

Method 2:

A: to use python 2 version (change the exe of python 3):

(1) the "python" to be executed:

Rename the python3 version "D:\ Program Files\ python3.5\ python.exe" to "D:\ Program Files\ python3.5\ python3.exe" so that it does not interfere.

Then the "Python?--version" executed is "python 2.7"

(2) to execute pip:

Execute "pip2-version" directly by cmd

B: to use the python 3 version

Then change the newly changed D:\ Program Files\ python3.5\ python3.exe back to the original python.exe.

In this way, it is very convenient to use python2 and python3 at the same time.

Note:

Can I change python.exe under python2 and python3 to Python2 and python3? So it can be used side by side? The answer is no!

At this point, I believe you have a deeper understanding of "how to use Python2 and Python3 at the same time". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report