Are python2.7 and 3.5 compatible?
Due to historical reasons, Python has two large version branches, Python2 and Python3. And because some libraries only support a certain version branch, Python2 and Python3 need to be installed on the computer at the same time. Therefore, how to use two versions of Python? Compatibility, how to make the script run on the corresponding Python version, this is worth summarizing.
For Ubuntu 16.04 LTS version, Python2 (2.7.12) and Python3 (3.5.2) are installed at the same time by default, and the default python version is 2.7.12.
Of course you can also use python2 to call it.
If you want to call python3, use python3.
Related recommendations: "Python Video Tutorial"
For Windows, it is a bit complicated. Because regardless of python2 or python3, the python executable file is called python.exe. The version number obtained by typing python in cmd depends on which version of the python path is higher in the environment variable. After all, Windows searches in order. For example, the order in the environment variable is like this:
Then the python version under cmd is 2.7.12.
On the contrary, it is the version number of python3.
This brings up a problem. If you want to use python2 to run a script, and later you want to use python3 to run another script, what do you do? Changing environment variables back and forth is obviously troublesome.
There are many methods on the Internet that are relatively simple and crude. Rename two python.exe, one to python2.exe and the other to python3.exe. This is certainly possible, but the method of modifying the executable file is not a good method after all.
I carefully searched some python technical documents and found another solution that I think is better.
Borrow a parameter of py to call different versions of Python. py -2 calls python2, py -3 calls python3
When the python script needs python2 to run, just before the script Add it and then run py xxx.py.
#! python2
When the python script needs python3 to run, just add, before the script, and then run py xxx.py.
#! python3
It’s that simple.
At the same time, this also perfectly solves the problem of pip reporting an error in an environment where python2 and python3 coexist, prompting Fatal error in launcher: Unable to create process using '"'.
When needed When using python2's pip, just
py -2 -m pip install xxx
When you need python3's pip, just
py -3 -m pip install xxx
The pip packages of python2 and python3 can be perfectly separated.
The above is the detailed content of Are python2.7 and 3.5 compatible?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will encounter freezes or blue screens when operating the computer. At this time, we need to find the most stable win10 version to operate. Overall, it is very easy to use and can make your daily use smoother. The most stable win10 version in history 1. Win10 genuine original system. Here users can use simple operations. The system has been optimized and has strong stability, security and compatibility. Users can follow the steps to achieve the perfect machine. 2. Russian master streamlined The version of win10 has been strictly streamlined and many unnecessary functions and services have been deleted. After streamlining, the system has lower CPU and memory usage and runs faster. 3. Win10 Lite Edition 1909 is installed on multiple computers with different hardware models.

Switch2 is a new model announced by Nintendo at Gamescom 2023. Some players are worried about whether there will be compatibility issues between the new model and the cartridges of previous versions. Let’s take a look. Is switch2 compatible with switch cassette? Answer: switch2 is not compatible with switch cassette. Introduction of Switch 2 cartridges According to information from Nintendo’s production chain company, Switch 2 may use 64GB cartridges. Because it has better performance and supports more 3A game masterpieces, it requires a larger cartridge capacity. Because many game works need to be castrated and compressed before they can be stuffed into a game cartridge. Moreover, Switch cartridges are prone to copying game content, so replace them with new cartridges.

As we all know, a major feature of win11 is its own Android subsystem, which allows us to install Android software without using an emulator. However, there is also the problem of win11 Android application lag. How should this be solved? Is win11 not compatible with dynamic wallpapers? Answer: Win11 is compatible with dynamic wallpapers. If it cannot be used, it may be because the software or system version is lagging behind. If it was just updated, it may be covered by the system wallpaper. 1. If the system or software version is lagging behind, just update the system and dynamic wallpaper software. 2. If it is covered by the system wallpaper, you can try to open "Settings" 3. Then enter the "Background" settings under "Personalization". 4. Then change the personalized background to "Picture" 5. After the modification is completed, you can set the dynamic wallpaper normally

The reason why many friends are still choosing win7 system instead of win10 system is that they are afraid of poor compatibility. In fact, win10 system can now set the compatibility mode of win7. You only need to change the settings in the properties. Let’s take a look at it together. How to make win10 compatible with win71? First, right-click on the program we need to run under win7 system, then open "Properties" 2, then click "Compatibility" above to enter the compatibility tab. 3. Check "Run this program in compatibility mode" in compatibility mode. 4. Then select "Windows 7" from the drop-down menu below. 5. After finishing, just click "Apply" or click "OK".

How to resolve d3dx9_43.dll incompatibility. In recent years, the rapid development of computers and games has allowed us to enjoy more entertainment and convenience. However, sometimes when installing or running certain programs, we may encounter some error messages, such as "d3dx9_43.dll is incompatible". In this case, how should we solve this problem? First, let’s understand what this error message means. d3dx9_43.dll is a system file of DirectX, which is used in the operating system

In recent years, the popularity of the Android system in the field of mobile devices has grown rapidly, and many people have begun to pay attention to whether Android applications can also be run on other platforms. As a common operating system, Linux is favored by many people. So the question is, is the Linux system compatible with Android software? The first thing to make clear is that the Linux system and the Android system have certain similarities in the kernel. They are both operating systems based on the Linux kernel. Therefore, theoretically speaking, the Linux system can run

There are many website users who need to use the old version of the browser when browsing, and the new version needs to add compatible outlets before they can be used, so today I will bring you a detailed tutorial on adding compatible outlets in win11. Come and learn. How to add compatible outlets in win11 1. First open the IE browser in the system, click the small gear in the upper right corner of the browser to enter "Settings". 2. Then in the settings menu that opens, open "Compatibility View Settings". 3. Enter the URL to be added in the edit box under Add this website, and then click "Add". 4. Finally, you can see the domain name of the added URL below, and you can access it directly by closing the window.

Can programs compiled by Mingw run normally under Linux systems? Many programmers often encounter such a problem during the development process, that is, whether the program compiled using Mingw under the Windows system can run normally under the Linux system. This article will explore this issue in detail and give specific code examples. First, we need to understand what Mingw is and the difference between it and Linux systems. Mingw is a development environment under Windows, used to compile Wind
