简体   繁体   中英

apt install virtualenv vs apt install python3-virtualenv

This question has many related questions, but none answers what I want to know:

I usually work like this:

  1. install python 3.5+
  2. sudo apt install virtualenv
  3. virtualenv -p /usr/bin/python3.* bla
  4. . bla/bin/activate
  5. pip install & run python

This seems to work perfectly, and I've done so also with python2.7. Is there a difference between using apt install virtualenv and apt install python3-virtualenv ?

Package virtualenv is described here: https://packages.debian.org/buster/virtualenv or https://packages.ubuntu.com/bionic/virtualenv . When you look at the files it contains you see that it consists only of a bit of documentation.

But virtualenv has dependencies packages python3 and python3-virtualenv. So if you install virtualenv those packages will also be installed.

Python 2 is not supported by upstream anymore, not even security fixes. So you simply should not use it.

apt install virtualenv应该安装python3-virtualenv我对此非常确定,但我认为这取决于您在终端上输入 python 时出现的内容,它应该与版本相关。

After some searching, I can say that package virtulenv is an overlay over python-virtualenv (Python 2 Virtual Env creator) and python3-virtualenv (Python 3 virtual Env creator). It is essential for command virtualenv to work (the one you type in terminal). Now, this command can internally use either of 2 versions provided by python.

Therefore, if you do sudo apt install virtualenv it automatically installs python3-virtualenv along with it. However, you can install virtualenv with python2-virtualenv as well.

So, difference is that virtualenv package is the one which provides command line options(invokable via terminal) while python3-virtualenv(for python 3) does actual job of creating environment and is replaceable by python-virtualenv(for python 2).

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.

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