最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Executing pyenv activate <virtualenv> before Eclipse with PyDev runs application - Stack Overflow

programmeradmin1浏览0评论

I need to use Eclipse with PyDev to debug an application that runs in a virtual environment. I establish the virtual environment with:

pyenv install 3.10.15
pyenv virtualenv 3.10.15 salt
pyenv activate salt

The application (salt-minion) is run from a script that looks like:

#!/usr/bin/env python3
"""
This script is used to kick off a salt minion daemon
"""

from multiprocessing import freeze_support

import salt.utils.platform
from salt.scripts import salt_minion

if __name__ == "__main__":

... stuff ...

    salt_minion()

However, to run this in a terminal session, I must first activate salt within that session, i.e.,

pyenv activate salt

When I create a Eclipse/PyDev project for the application and try to run it in debug mode from there, I get the following error:

0.01s - warning: Debugger speedups using cython not found. Run '"/home/dan/dotpyenv/versions/3.10.15/bin/python3.10" "/home/dan/.var/app/.eclipse.Java/eclipse/plugins/.python.pydev.core_12.2.0.202409031913/pysrc/setup_pydevd_cython.py" build_ext --inplace' to build.
pydev debugger: starting (pid: 198)
Traceback (most recent call last):
File "/home/dan/.var/app/.eclipse.Java/eclipse/plugins/.python.pydev.core_12.2.0.202409031913/pysrc/pydevd.py", line 3699, in <module>
main()

... Traceback stuff ...

File "/home/dan/SaltSource/3006.x/salt/salt/utils/platform.py", line 12, in <module>
import distro
ModuleNotFoundError: No module named 'distro'

I believe this is because I haven't activated salt so Eclipse/PyDev can access the dependencies. Is there a way in Eclipse/PyDev to call pyenv activate salt before running the application (specifically in debug mode)?

发布评论

评论列表(0)

  1. 暂无评论