Installing pythonstartup file

后端 未结 4 2054
别那么骄傲
别那么骄傲 2020-12-03 07:58

How do I install the pythonstartup file so that it runs on command like python myfile.py?

I tried to install it into my /home/myuser<

4条回答
  •  借酒劲吻你
    2020-12-03 08:32

    In your ~/.bashrc:

    export PYTHONSTARTUP=$HOME/.pythonstartup
    

    and put your python code in $HOME/.pythonstartup, like:

    import rlcompleter
    import readline
    
    readline.parse_and_bind("tab: complete")
    

    Then run the interactive shell:

    python
    

    See the imports from PYTHONSTARTUP are processed. This only works in python interactive mode.

    For more information about PYTHONSTARTUP variable, read the python man page:

    $ man python
    

提交回复
热议问题