Piotr Dobrogost
Piotr Dobrogost

Reputation: 42465

Where is pyvenv script in Python 3 on Windows installed?

After reading the following statement from PEP 405

A pyvenv installed script is also provided to make this more convenient:

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.

Is PEP 405 wrong, was it not properly implemented in Python 3.3 or am I missing something?

Upvotes: 10

Views: 7847

Answers (2)

George Sovetov
George Sovetov

Reputation: 5238

Use python -m venv someenvname instead.

Moreover, there is no strong reason to add python folder to PATH if you use system-wide python.exe only for creating virtual environments.

Upvotes: 3

Piotr Dobrogost
Piotr Dobrogost

Reputation: 42465

It looks like pyvenv script is placed in Tools\Scripts subfolder inside Python installation folder (sys.prefix). 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). As there's no exe wrapper for this script one has to make sure

  • .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 extension is associated either with Python executable or with Python launcher (py.exe) which is available starting from Python 3.3

Alternatively one can just type python -m venv instead of pyvenv and save himself all of the hassle...

Related Python bug 17480 - pyvenv should be installed someplace more obvious on Windows

Upvotes: 15

Related Questions