How can I run pdb from emacs on a file that is activated in a given conda environment.
I have setup exec-path and PATH to contain the current conda path, eg.
exec-path
("~/miniconda3/envs/sci/bin" ...)
(getenv "PATH")
"~/miniconda3/envs/sci/bin:..."
From within emacs,
(executable-find "python")
"~/miniconda3/envs/sci/bin/python
returns the proper python. pdb is located at "/usr/bin/pdb". However, if I run pdb on a file that is running in the sci conda environment, eg. its has numpy, etc. installed, pdb can't find those libraries:
test.py
import numpy as np
import pandas as pd
tst = np.linspace(1, 10, num=10)
print(tst)
pdb ./test.py
Current directory is
~/scratch/python/
>
~/scratch/python/test.py(1)<module>()
-> import numpy as np
(Pdb) n
ImportError: 'No module named numpy'
>
~/scratch/python/test.py(1)<module>()
-> import numpy as np
(Pdb)
Customizing
gud-pdb-command-nametopython -m pdbseems to work.So, pdb
python -m pdb ./test.pyruns in the correct environment.