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?
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 ofpython3 -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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.