简体   繁体   English

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

[英]How to use two different Python Versions in the same File or Project?

I have written some code in cntk, which needs Python Version 3.6 or older.我在cntk中写了一些代码,需要Python 3.6或更早的版本。 The problem is that I want to use this code in a Project, which only allows Python 3.8 or newer.问题是我想在项目中使用此代码,它只允许 Python 3.8 或更新版本。 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.编辑:3.6 代码做了一些深度学习预测,应该从 3.8 项目中调用它们以将它们用于其他计算。

On Windows they get installed to separate folders, "C:\python26" and "C:\python31", but the executables have the same "python.exe" name.在 Windows 上,它们被安装到单独的文件夹“C:\python26”和“C:\python31”,但可执行文件具有相同的“python.exe”名称。

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.我创建了另一个“C:\python”文件夹,其中包含“python.bat”和“python3.bat”,分别作为“python26”和“python31”的包装器,并将“C:\python”添加到 PATH 环境变量.

This allows me to type python or python3 in my.bat Python wrappers to start the one I desire.这允许我在 my.bat Python 包装器中键入 python 或 python3 以启动我想要的包装器。

On Linux, you can use the #.在 Linux 上,您可以使用#。 trick to specify which version you want a script to use.指定您希望脚本使用哪个版本的技巧。

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

相关问题 如何在 python pandas 中合并两个不同版本的相同数据框? - How to merge two different versions same dataframe in python pandas? 在两个不同版本的 Python 上安装相同的 package - Install the same package on two different versions of Python 在同一脚本中使用两个单独的python版本 - Use two separate versions of python in the same script python 的两个版本为相同的代码给出了两个不同的结果 - Two versions of python giving two different results for the same code 如何创建两个具有不同 python 版本的 virtualenv? - How to create two virtualenv with different python versions? 如何在 Python 的一个程序中导入/使用库(pytorch)的两个不同版本? - How can I import/use two different versions of a library (pytorch) in one program in Python? 命令行 python 和 jupyter notebook 使用两个不同版本的 torch - Command line python and jupyter notebooks use two different versions of torch 如何同时导入同一个python模块的两个版本? - How to import two versions of the same python module at the same time? Python——从同一个项目中不同目录的两个不同文件访问相对文件路径 - Python— access relative file path from two different files from different directory in same project 如何为Python 2.7和Python 3.4设置两个不同的pip版本? - How to set two different pip versions for Python 2.7 and Python 3.4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM