search
HomeBackend DevelopmentPython TutorialAre 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.

Are python2.7 and 3.5 compatible?

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.

Are python2.7 and 3.5 compatible?

Of course you can also use python2 to call it.

Are python2.7 and 3.5 compatible?

If you want to call python3, use python3.

Related recommendations: "Python Video Tutorial"

Are python2.7 and 3.5 compatible?

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:

Are python2.7 and 3.5 compatible?

Then the python version under cmd is 2.7.12.

Are python2.7 and 3.5 compatible?

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

Are python2.7 and 3.5 compatible?

Are python2.7 and 3.5 compatible?

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!

Statement
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
Win10的最稳定版本Win10的最稳定版本Dec 25, 2023 pm 07:58 PM

很多用户都会遇到在操作电脑的时候卡顿或者是蓝屏,这个时候我们就需要找一个最为稳定的win10版本来进行操作,整体都是非常的好用的,可以让你日常使用更为流畅。史上最稳定的win10版本1、win10正版原装系统在这里用户可以使用简单的操作,系统经过优化,具有很强的稳定性、安全性、兼容性,用户可以按照步骤实现完美机器2、俄罗斯大神精简版win10经过严格的精简操作,删除了很多不必要的功能和服务。精简后,系统的CPU和内存占用率更低,运行速度更快。3、win10精简版1909安装多台不同硬件型号的电脑

Switch2能兼容Switch卡带吗?Switch2能兼容Switch卡带吗?Jan 28, 2024 am 09:06 AM

Switch2是任天堂在2023年科隆游戏展公布的新机型,一些玩家担心新出来的机型与之前版本的机型卡带会不会存在兼容性问题,下面我们一起来看看吧。switch2兼容switch卡带吗答:switch2不兼容switch卡带。Switch2卡带的介绍根据任天堂的生产链公司的消息称,Switch2可能会使用64GB的卡带。它由于性能更好,支撑更多的3A游戏大作的原因,需要更大卡带容量。因为很多的游戏作品需要阉割和压缩,才能塞进一张游戏卡带里面。而且Switch的卡带容易被复制游戏内容,所以更换新卡带

Win11是否支持动态壁纸Win11是否支持动态壁纸Jan 01, 2024 pm 06:41 PM

众所周知,win11一大特色就是自带安卓子系统,让我们不需要用模拟器就可以安装安卓软件,但也存在win11安卓应用卡顿的问题,这应该怎么解决呢。win11不兼容动态壁纸么:答:win11能兼容动态壁纸,如果用不了可能是软件或系统版本落后。如果是刚更新,可能是被系统壁纸覆盖了。1、如果是系统或软件版本落后,那么更新一下系统和动态壁纸软件即可。2、如果是被系统壁纸覆盖了,可以尝试打开“设置”3、接着进入“个性化”下的“背景”设置。4、然后将个性化设置背景改为“图片”5、修改完成后就能正常设置动态壁纸

win10兼容win7的设置方法介绍win10兼容win7的设置方法介绍Jan 03, 2024 pm 05:09 PM

很多朋友目前还在选择win7系统而不是win10系统的原因就是害怕其兼容性不好。其实,现在win10系统已经可以设置win7的兼容模式了,只需要在属性中就可以更改设置,下面就一起来看一下吧。win10怎么兼容win71、首先右键点击我们需要在win7系统下运行的程序,然后打开“属性”2、然后点击上方的“兼容性”,进入兼容性选项卡。3、在兼容模式下勾选“以兼容模式运行这个程序”4、然后就可以在下方的下拉菜单中选择“windows7”5、完了之后只需要点击“应用”或者点击“确定”就可以了。

Mingw编译的程序能否在Linux系统下正常运行?Mingw编译的程序能否在Linux系统下正常运行?Mar 19, 2024 pm 12:03 PM

Mingw编译的程序能否在Linux系统下正常运行?许多程序员在开发过程中常常会遇到这样一个问题,即在Windows系统下使用Mingw进行编译后的程序能否在Linux系统下正常运行。本文将详细探讨这个问题,并给出具体的代码示例。首先,我们需要了解Mingw是什么以及它和Linux系统之间的差异。Mingw是一个在Windows下的开发环境,用于编译Wind

介绍win10系统与ps版本的兼容性介绍win10系统与ps版本的兼容性Dec 30, 2023 pm 06:04 PM

ps也就是Photoshop,它是目前很多人都在使用的图片处理软件。很多朋友在使用ps前,可能会发现某些ps无法安装在win10系统中,怀疑是兼容的问题,因此今天小编就来给大家介绍一下win10兼容哪个版本的ps。win10兼容哪个ps答:现在几乎所有版本都能兼容,配置越高的电脑可以使用越新的版本。1、现在win10的兼容性已经很好了,只要配置足够,几乎可以兼容所有版本的ps。2、ps对于电脑配置的要求是比较高的,因此如果大家配置高的话可以使用最新版本的ps。3、如果配置不够的话,可以下载使用P

Win11安装及配置兼容网络点的详细指南Win11安装及配置兼容网络点的详细指南Jan 09, 2024 pm 02:50 PM

有不少网站用户们在浏览的时候都会需要使用旧版本的浏览器才能够使用,而新版本的需要添加兼容网点才可以进行使用,所以今天就给你们带来了win11添加兼容网点详细教程,快来学习一下吧。win11如何添加兼容网点1、首先打开系统中的IE浏览器,点击浏览器右上角小齿轮进入“设置”。2、然后在打开的设置菜单中,打开“兼容性视图设置”。3、在添加此网站下的编辑框中输入要添加的网址,然后点击“添加”。4、最后在下方就可以看到添加网址的域名了,关闭窗口即可直接访问。

解决d3dx9_43.dll不兼容的方法解决d3dx9_43.dll不兼容的方法Feb 24, 2024 pm 10:06 PM

d3dx9_43.dll不兼容怎么解决近年来,计算机和游戏的快速发展使得我们享受到了更多的娱乐和便利。然而,有时在安装或运行某些程序时,我们可能会遇到一些错误信息,例如“d3dx9_43.dll不兼容”。在这种情况下,我们应该如何解决这个问题呢?首先,让我们来了解一下这个错误信息的含义。d3dx9_43.dll是DirectX的一个系统文件,它是用于在操作系

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),