如何在同一个文件或项目中使用两个不同的Python版本?

发布于 2025-01-14 15:58:51 字数 153 浏览 2 评论 0原文

我在cntk中编写了一些代码,需要Python版本3.6或更早版本。问题是我想在项目中使用此代码,该项目仅允许 Python 3.8 或更高版本。结合这两个程序的最佳解决方案是什么?

编辑: 3.6 代码做了一些深度学习预测,应该从 3.8 项目中调用它们以将它们用于其他计算。

I have written some code in cntk, which needs Python Version 3.6 or older. The problem is that I want to use this code in a Project, which only allows Python 3.8 or newer. What's the best solution to combine these two programms?

EDIT:
The 3.6 code does some deep learning predictions, which should be called from the 3.8 project to use them for other computations.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2025-01-21 15:58:52

在 Windows 上,它们安装到单独的文件夹“C:\python26”和“C:\python31”,但可执行文件具有相同的“python.exe”名称。

我创建了另一个“C:\python”文件夹,其中包含“python.bat”和“python3.bat”,分别用作“python26”和“python31”的包装器,并将“C:\python”添加到 PATH 环境变量。

这允许我在 .bat Python 包装器中输入 python 或 python3 来启动我想要的包装器。

在 Linux 上,您可以使用 #!指定您希望脚本使用哪个版本的技巧。

On Windows they get installed to separate folders, "C:\python26" and "C:\python31", but the executables have the same "python.exe" name.

I created another "C:\python" folder that contains "python.bat" and "python3.bat" that serve as wrappers to "python26" and "python31" respectively, and added "C:\python" to the PATH environment variable.

This allows me to type python or python3 in my .bat Python wrappers to start the one I desire.

On Linux, you can use the #! trick to specify which version you want a script to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文