Home > Backend Development > Python Tutorial > Configuration method for coexistence of multiple versions of Python

Configuration method for coexistence of multiple versions of Python

不言
Release: 2018-04-18 14:19:09
Original
1901 people have browsed it

This article shares with you the development environment of python2 and python3 required to be installed on the PC due to work requirements. So how should we operate? Let’s discuss it below.

In the same PC, if Python2 and Python3 environments are installed at the same time, an error will occur when executing the python command, and the operating system will find the default configuration for execution. How can we make python2 and python3 work together without affecting each other?

However, due to work needs, we may need multiple python versions to coexist on our personal PCs. What kind of settings should be made? This chapter will analyze and introduce the use of this issue

1. To configure the coexistence of python2 and python3 versions, enter the installation path of python2 as follows


The file in the Python2 installation path.png

Modify python.exe and rename it to python2.exe


##python2 rename the file.png

Enter python3 Installation path


File under the python3 installation path

Rename the file python.exe to python3.exe and pythonw.exe to pythonw3.exe


python3 environment rename file.png

Configure environment variables and configure the paths of python2 and python3 to the path environment variable


Environment variable configuration.png

At this time, we open the command line window of the system, enter the command python2 to enter the python2 development environment, enter the named python3 to enter the python3 development environment


Enter the environment of python2 and python3.png

2. Commands executed when pip installs modules

Under normal circumstances, we also need to use the python pip command Install and configure third-party modules. If you execute Pip directly at this time, an error will occur.

The general installation command syntax is as follows


Copy code The code is as follows:

pip install module name

However, we installed two versions of python on the PC and modified the name of the executable file python.exe, so an error will occur when directly executing pip.

2.1. Install third-party modules for python2

Open the command line tool and execute the following command to install the modules required for python2


Copy code The code is as follows:

python2 -m pip install module name

2.2. Install third-party modules for python3

Open the command line tool and execute Use the following command to install the modules required for python3


Copy code The code is as follows:

python3 -m pip install module name

2.3. Check the pip version

Execute the pip command in the specified version of python.png

The above is the detailed content of Configuration method for coexistence of multiple versions of Python. For more information, please follow other related articles on the PHP Chinese website!

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