windows同时安装python2和3编码_windows同时安装python2和python3

系统之前安装了python2.7,现在准备装个python3.6

1:首先下载一个python3.6适合windows32位的包python-3.6.5.exe

然后直接默认双击安装,安装的时候勾选add to path

默认安装路径C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32

进入这个路径把python.exe修改成python3.exe这样在dos下直接python3,就可以进入python3的环境了,

怎么进入python2呢?默认输入python

2 关键是怎样使用python3的pip安装模块,我是这做的,当然还有其他方法

进入python3的pip目录下cd C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Scripts

执行命令 python3 -m pip install 包名

验证import requests

第二种方法:可以将路径添加到环境变量中C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Scripts

然后直接执行python3 -m pip install requests,这种方法也是可以的

在安装一个django,支持python3的版本

3还有一个比较重要的,之前的代码在idle中,怎样选择是在python2还是python3环境中运行呢?

这里在打开的会后选择你要运行的环境就可以了

同理,再sublime中可可以配置python2和python3的环境

在tool---build system--new build system中新建一个名字保存为python3

将下面粘贴进去

{

"cmd": ["自己的python3安装目录/python3.exe","-u","$file"],

"file_regex":"^[ ]*File \"(...*?)\", line ([0-9]*)",

"selector":"source.python",

"encoding": "utf-8" ,

"env": { "PYTHONIOENCODING": "utf8" },

}

重启sublime,然后选择python的build system 编写python文件,ctrl+b运行python文件就可以

=========================================================================================================

=========================================================================================================

如果python2和python3同事都安装了pytest,这时候想指定pytest的运行环境,该怎么处理

python3 pytest 会报错python3: can't open file 'pytest': [Errno 2] No such file or directory

解决方法:

python3 -m pytest

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值