简体   繁体   English

带有 miniconda python 环境的 Emacs gud-pdb

[英]Emacs gud-pdb with miniconda python environments

How does one get emacs to use the same PATH to the python and pdb executables as I get from the term when I have set a specific miniconda environment?当我设置了特定的 miniconda 环境时,如何让 emacs 使用与我从术语中得到的相同的 PATH 到 python 和 pdb 可执行文件?

Ie in emacs, when I run Mx pdb , I would like it to use the same executable as I do if I have done the following from the term:即在 emacs 中,当我运行Mx pdb ,如果我从术语中完成了以下操作,我希望它使用与我相同的可执行文件:

$ source activate my_py3_env
$ pdb

I know currently this isn't what is happening.我知道目前这不是正在发生的事情。 I switch to a python 3 env, which modifies my PATH appropriately, but when I run Mx pdb for a python script and print sys.version from within that script I get:我切换到 python 3 env,它适当地修改了我的 PATH,但是当我为 python 脚本运行Mx pdb并从该脚本中打印 sys.version 时,我得到:

2.7.17 |Anaconda, Inc.| (default, Oct 21 2019, 19:04:46) 

So it seems to be picking up the 'base' miniconda env which is still 2.7所以它似乎正在选择仍然是 2.7 的“基础”miniconda env

I would half of expected it to pick up whats in /usr/bin but that doesn't seem to be the case, ie if I execute:我有一半预期它会获取 /usr/bin 中的内容,但情况似乎并非如此,即如果我执行:

$ /usr/bin/python

I get我得到

Python 2.7.15+ (default, Oct  7 2019, 17:39:04) 

To summarise, is there a way to get emacs Mx pdb to 'follow' the conda environment I am currently in without me having to manually specify the location of the pdb executable for each environment?总而言之,有没有办法让 emacs Mx pdb “跟随”我目前所处的 conda 环境,而不必手动为每个环境指定 pdb 可执行文件的位置?

You can find the conda or virtualenv python path with (swap in the analogous conda equivalent for starting the env): source .py2james/bin/activate and which python in the terminal.您可以找到conda或 virtualenv python 路径(在用于启动 env 的类似 conda 中交换): source .py2james/bin/activatewhich python在终端中。 Note the path to the python exe.注意python exe的路径。

you can do: option + x pdb你可以这样做: option + x pdb

then: /Users/janderson/code/python/awsomeapp/.py2james/bin/python -m pdb main.py and the emacs pdb debugger will start.然后: /Users/janderson/code/python/awsomeapp/.py2james/bin/python -m pdb main.py和 emacs pdb 调试器将启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM