zoukankan      html  css  js  c++  java
  • windows同时安装python2和python3

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

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

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

    默认安装路径C:UsersAdministratorAppDataLocalProgramsPythonPython36-32

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

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

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

    进入python3的pip目录下cd C:UsersAdministratorAppDataLocalProgramsPythonPython36-32Scripts

    执行命令 python3 -m pip install 包名

     验证import requests

     第二种方法:可以将路径添加到环境变量中C:UsersAdministratorAppDataLocalProgramsPythonPython36-32Scripts

    然后直接执行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

  • 相关阅读:
    DNS服务器出错造成“不知道这样的主机”
    downadup.B蠕虫病毒处理手记
    今天新接触到一个名词——GSV
    客户端获取SQL服务端的MAC
    关于SQL事务的测试
    ftp://ftp.microsoft.com
    AJAX.DLL的使用
    "界面规则层与业务规则层"让我想开了
    客户端cookie也会传到服务端的Request.Params?
    Ext.Fx
  • 原文地址:https://www.cnblogs.com/xueli/p/8715673.html
Copyright © 2011-2022 走看看