zoukankan      html  css  js  c++  java
  • Windows 下Python的一些设置

    Key Words: Python, Windows, pip, readline

      肇因是想在Windows下能够代码补全,需要自己添加模块,添加了又缺readline模块,安装时候又想装pip……完全就是个递归。

      一个个解决。

      首先建一个模块: 

    #!/usr/bin/env python
    import sys 
    import atexit
    import os
    import readline
    import rlcompleter
    readline.parse_and_bind('tab: complete')
    histfile = os.path.join(os.environ['HOME'],'pythonhistory')
    try:
        readline.read_history_file(histfile)
    except IOError:
        pass
    atexit.register(readline.write_history_file, histfile)
    del os, histfile, readline, rlcompleter

      貌似大家都是这么写的。

      之后,我在 import这个模块的时候遇到了几个问题:

    1、没有readline模块,第一步就卡住。

    2、没有HOME的环境变量,这个倒好说,但是挺关键。

       辛苦下了readline-6.2.4.1,运行python setup.py install,结果提醒不支持win系统。又搜了下说pyreadline可以替代readline在windows下的功能。

    懒得找了想用pip安(后来找到了,pyreadline),但是又得先安pip,下载好pip ,安装。

      这下readline的问题解决了,在环境变量中加上PYTHONSTARTUP,值是之前那个模块的绝对路径,之后每次启动Python就都会加载这个模块。

  • 相关阅读:
    Git回退---reset和revert
    XML解析
    SpringBoot学习day01
    Spring boot精要
    JS没有contains方法,可以用indexof实现
    git fetch 取回所有分支(branch)的更新(转)
    idea 设置注释模板
    git退出编辑模式
    git 提交代码到远程分支
    linux下,保存退出vim编辑器(转)
  • 原文地址:https://www.cnblogs.com/hyace/p/3859434.html
Copyright © 2011-2022 走看看