简体   繁体   English

安装在Windows 3上的Python 3中的pyvenv脚本在哪里?

[英]Where is pyvenv script in Python 3 on Windows installed?

After reading the following statement from PEP 405 阅读PEP 405中的以下声明后

A pyvenv installed script is also provided to make this more convenient: 还提供了pyvenv安装的脚本,以使这更方便:

pyvenv /path/to/new/virtual/environment

I tried to create a new virtual environment and failed miserably; 我试图创建一个新的虚拟环境并且失败了;

C:\>python --version
Python 3.3.1
C:\>pyvenv myvenv
'pyvenv' is not recognized as an internal or external command,
operable program or batch file.

Apparently pyvenv script is not installed into Scripts folder which is being usually added to the PATH environment variable making it possible to easily run such scripts on the command line. 显然, pyvenv脚本未安装到Scripts文件夹中,该文件夹通常被添加到PATH环境变量中,从而可以在命令行上轻松运行此类脚本。

Is PEP 405 wrong, was it not properly implemented in Python 3.3 or am I missing something? PEP 405是错误的,是否在Python 3.3中没有正确实现,或者我错过了什么?

It looks like pyvenv script is placed in Tools\\Scripts subfolder inside Python installation folder ( sys.prefix ). 看起来pyvenv脚本放在Python安装文件夹( sys.prefix )中的Tools\\Scripts子文件夹中。 It seems like copying it to Scripts subfolder is a good idea as it allows to simply type pyvenv from the command line (assuming Scripts folder is already on the PATH ). 似乎将其复制到Scripts子文件夹是一个好主意,因为它允许pyvenv简单地键入pyvenv (假设Scripts文件夹已经在PATH )。 As there's no exe wrapper for this script one has to make sure 因为这个脚本没有exe包装器,所以必须确保

  • .py extension is added to PATHEXT environment variable so that Windows finds Python script placed on the PATH when typing script's name at the command prompt. .py扩展名被添加到PATHEXT环境变量中,以便Windows在命令提示符下键入脚本名称时找到放置在PATH上的Python脚本。
  • .py extension is associated either with Python executable or with Python launcher ( py.exe ) which is available starting from Python 3.3 .py扩展名与Python可执行文件或Python启动程序( py.exe )相关联,Python启动器从Python 3.3开始提供

Alternatively one can just type python -m venv instead of pyvenv and save himself all of the hassle... 或者,可以只输入python -m venv而不是pyvenv并节省所有麻烦...

Related Python bug 17480 - pyvenv should be installed someplace more obvious on Windows 相关的Python bug 17480 - pyvenv应该安装在Windows上更明显的地方

Use python -m venv someenvname instead. 请改用python -m venv someenvname

Moreover, there is no strong reason to add python folder to PATH if you use system-wide python.exe only for creating virtual environments. 此外,如果仅使用系统范围的python.exe创建虚拟环境,则没有充分的理由将python文件夹添加到PATH

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

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