推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
wyc9296
V2EX  ›  Python

sublimeText3 的 REPL 怎么在虚拟环境下 run current file? - Python

  •  1
     
  •   wyc9296 · Jul 10, 2019 · 2983 views
    This topic created in 2641 days ago, the information mentioned may be changed or developed.

    看中了 REPL 可以分屏,可以有交互界面、dos 界面、还可以直接 run 脚本。直接 run 时,对于一些一直运行的脚本,如 flask,可以右键 kill 掉,这点比 build system 有优势多了。

    但是,ctrl shift+P 打开 command_palette 后,输入SublimeREPL: Python-virtualenv,选择某个虚拟环境后,就直接转到 python 交互界面了:

    Python 3.5.4 (v3.5.4, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> 
    

    直接运行这个 file 的话(tool->sublimeREPL->python->python - run current file),只能在 global 的 python 环境下运行。

    1 replies  •  2019-07-10 15:12:32 +08:00
    wyc9296
        1
    wyc9296  
    OP
       Jul 10, 2019
    研究了半天,我自己暂时的解决办法:
    (##how to run current file in sublimeREPL with python virtualenv )
    1. 记得修改一下 python_virtualenv_paths,把它设置成"~\\Envs"
    2. 在 packages\sublimeREPL 中找到 lang_integration.py,把 PythonVirtualenvRepl 这个 class 中的
    ```
    "cmd": [python_executable, "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],改
    ```
    改为
    ```
    "cmd": [python_executable, "-u", "$file_basename"],
    ```
    3. 快捷键设置:
    ```
    {
    "keys":["f5"],
    "caption": "SublimeREPL: Python - RUN current file",
    "command": "run_existing_window_command",
    "args": {
    "id": "python_virtualenv_repl",
    "file": "config/Python/Main.sublime-menu"
    }
    },
    ```
    打算从现在开始起不用 pycharm 了,速度太慢了。运行 flask app 时如果想停止,直接右键 kill 即可。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2322 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 81ms · UTC 09:30 · PVG 17:30 · LAX 02:30 · JFK 05:30
    ♥ Do have faith in what you're doing.