简体   繁体   English

如果 pyenv 设置为针对 python 的多个版本运行,如何运行 python 代码

[英]How to run python code if pyenv is setup to run against multiple versions of python

We have our admin team setup PYENV so that we can run against multiple versions of python.我们的管理团队设置了 PYENV,以便我们可以针对 python 的多个版本运行。

we have two versions of python Python 2 and Python 3. How do I run my scripts against python 3?我们有两个版本的 python Python 2 和 Python 3. 我如何针对 Z23EEEB7347B7556BDDZ 运行我的脚本?

For example, when I just run like Python test.py it always run against python2 but I want to run my script with Python3.例如,当我像 Python test.py 一样运行时,它总是针对 python2 运行,但我想用 Python3 运行我的脚本。

Thank you for your help.谢谢您的帮助。

if you are using mac in terminal write ( python3 (name of the file).py如果您在终端写入中使用mac(python3(文件名).py

That depends.那要看。

If you want to use python3.x globally, you can run pyenv global 3.x to set the specific python version you want as your global version.如果要全局使用python3.x ,可以运行pyenv global 3.x将您想要的特定 python 版本设置为全局版本。

However, if you want to use python3.x for that specific script only, run python3.x path/to/specific/script.py但是,如果您只想将python3.x用于该特定脚本,请运行python3.x path/to/specific/script.py

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM