简体   繁体   English

如何运行两个版本的python 2.7.15和3.6.4,以及如何将软件包安装到特定版本的python?

[英]how can i run two versions of python 2.7.15 and 3.6.4 and How to install packages to specific version of python?

I'm using python 3.6.4 and 2.5.17 windows 10 and when I try to run any code, it only runs using version 2.7.15 I've tried to add to the first line of my code: 我正在使用python 3.6.4和2.5.17 Windows 10,当我尝试运行任何代码时,它仅使用2.7.15版运行,我尝试将其添加到代码的第一行:

#! python3

or 要么

#! python2

and nothing happened and I also tried to use 没有任何反应,我也尝试使用

py -the number of versions

i have this output: 我有这个输出:

'py' is not recognized as an internal or external command, operable program or batch file.

and if I wanna download anything using pip or pip3 command for python 3.6.4 it only installs it for python 2.7.15. 如果我想使用pippip3命令为python 3.6.4下载任何内容,则仅为python 2.7.15安装。 I've checked the environment variables I have python 2.7.15 and 3.6.4 included Can anyone one help me? 我检查了包含python 2.7.15和3.6.4的环境变量,有人可以帮助我吗?

edit: 编辑:

i have the py launcher installed on my PC : 我在PC上安装了py启动器:

see here 看这里

and when i try to run it : 当我尝试运行它时:

see here 看这里

and python files are included in the system variables 和python文件包含在系统变量中

see here 看这里

and the python 3.6.4 directory only contain thous files : 并且python 3.6.4目录仅包含大量文件:

see here 看这里

so what i have to do to run two versins of python now ?? 所以我现在要运行两个versins的python ?? and how to run scripts in atom ? 以及如何在Atom中运行脚本?

Not sure about windows, but if you have installed Anaconda prompt for windows, then you can install different versions of python on Anaconda prompt and give them specific names. 不确定Windows,但是如果您已经为Windows安装了Anaconda提示符 ,则可以在Anaconda提示符下安装不同版本的python,并为其指定特定的名称。 Like for me, I have python3.6.5 version named as base version and the python2.7 version as py27 . 像我一样,我将python3.6.5版本命名为base版本,并将python2.7版本命名为py27 Whenever I need to switch to either of them, I just use activate command: 每当我需要切换到它们中的任何一个时,我都只需使用activate命令:

activate py27 //to switch to python2.7

activate base    //to switch to python3.6.5

This automatically switches me to specified version of python in the anaconda prompt and then you can work it whichever way you like. 这会自动在anaconda提示符下将我切换到指定版本的python,然后您可以按照自己喜欢的方式进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM