gpt4 book ai didi

python - 如何在 virtualenv 中使用 Python Tools for Visual Studio 运行 python 脚本?

转载 作者:太空狗 更新时间:2023-10-29 22:11:41 26 4
gpt4 key购买 nike

我不知道如何在 Visual Studio 项目的 Python 工具中运行 activate.bat。我的项目中有一个带有 virtualenv 的目录环境。但是,我不知道如何在项目运行我的主要 python 脚本之前运行 ./env/Scripts/activate.bat

最佳答案

我通常将 Visual Studio 指向自定义 startup.py 脚本,然后我可以使用任何其他批处理文件运行:

# startup.py
import os
import main.py # Whatever your main script is
os.system('activate.bat') # Call your batch files.
main.run() # Call whatever you need to from your main script.

在 Visual Studio 中

  • 右键单击项目
  • 属性
  • 一般
  • 启动文件下,放入startup.py (随便)
  • 确保你的工作目录是正确的

关于python - 如何在 virtualenv 中使用 Python Tools for Visual Studio 运行 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11824589/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com