rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 程序开发 » Python

ubuntu10.04为Python配置环境

Vim

vim can be used very effectively for Python development, but Ubuntu only comes with the vim-tiny package installed by default, so it doesn’t support color syntax highlighting or auto-indenting.

To use Vim, do the following:

  • From the unix command prompt, run:

    $ sudo apt-get install vim-gnome
  • Create a file in your home directory named .vimrc that contains the following:

    syntax enable
    filetype indent on
    set et
    set sw=4
    set smarttab
    map <f2> :w\|!python %
  • When you edit a file with a .py extension, you should now have color systax highlighting and auto indenting. Pressing the key should run your program, and bring you back to the editor when the program completes.

    To learn to use vim, run the following command at a unix command prompt:

    $ vimtutor
    $HOME environment

    The following creates a useful environment in your home directory for adding your own Python libraries and executable scripts:

  • From the command prompt in your home directory, create bin and lib/python subdirectories by running the following commands:

    $ mkdir bin lib
    $ mkdir lib/python
  • Making a python script executable and runnable from anywhere

    On unix systems, Python scripts can be made executable using the following process:

  • Add this line as the first line in the script:

    #!/usr/bin/env python
  • At the unix command prompt, type the following to make myscript.py executable:

    $ chmod +x myscript.py
  • Move myscript.py into your bin directory, and it will be runnable from anywhere.


  • 顶一下
    (0)
    踩一下
    (0)