Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 958
Piotr Dobrogost Avatar asked Apr 12 '13 21:04

Piotr Dobrogost


2 Answers

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

like image 89
Piotr Dobrogost Avatar answered Oct 17 '22 01:10

Piotr Dobrogost


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.

like image 44
George Sovetov Avatar answered Oct 17 '22 02:10

George Sovetov