0

I'm making a concerted effort to understand how Python packaging works and I keep seeing the following idiom being used over and over. For example, if you're using venv to create a virtual environment, you can do this...

python3 -m venv tutorial_env

or you can do this

pyvenv tutorial_env

Under the hood, what is the real difference between using python3 to create the virtual environment and using pyvenv to create it? Why would you use one command rather than the other?

Jim
  • 13,430
  • 26
  • 104
  • 155
  • I guess this could help: [difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe](https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe) – Mayank Porwal Dec 08 '18 at 19:44
  • 1
    Thanks. Your link lead me to this link https://stackoverflow.com/questions/29950300/what-is-the-relationship-between-virtualenv-and-pyenv which says that pyvenv is a wrapper around venv that was deprecated in Python 3.6. This link https://docs.python.org/dev/whatsnew/3.6.html#id8 tells why pyvenv was deprecated. – Jim Dec 08 '18 at 19:59
  • you can write the answer to your question – Walter Tross Dec 08 '18 at 20:15

2 Answers2

0

According to python docs both are equivalent. Here is the pvenv script from python 3.4 source code:

#!/usr/bin/env python3
if __name__ == '__main__':
    import sys
    rc = 1
    try:
        import venv
        venv.main()
        rc = 0
    except Exception as e:
        print('Error: %s' % e, file=sys.stderr)
    sys.exit(rc)

Note:

The pyvenv script shipped with Python 3 but has been deprecated in Python 3.6+ in favour of python3 -m venv. This prevents confusion as to what Python interpreter pyvenv is connected to and thus what Python interpreter will be used by the virtual environment.

naman
  • 482
  • 4
  • 10
0

Mayank Porwal's answer lead me to this question which says that pyvenv is a wrapper around venv that was deprecated in Python 3.6.

This What's New in Python 3.6 tells why pyvenv was deprecated.

Jim
  • 13,430
  • 26
  • 104
  • 155