首页 > 解决方案 > 如何让`python3 -m venv`在环境中安装新版本的pip?

问题描述

我试图理解为什么这两个命令会在我的 MacOS 中产生不同的结果:

leme:Temp ar$ virtualenv env1
Using base prefix '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/ar/Temp/env1/bin/python3.7
Also creating executable in /Users/ar/Temp/env1/bin/python
Installing setuptools, pip, wheel...
done.
leme:Temp ar$ source env1/bin/activate
(env1) leme:Temp ar$ pip install pygments
Collecting pygments
  Using cached https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl
Installing collected packages: pygments
Successfully installed pygments-2.4.2
(env1) leme:Temp ar$ deactivate

在第二种情况下,如果我将它用作模块,它会发出关于使用 pip 19.0.3 版本的警告!我的系统中没有安装这个旧版本:

leme:Temp ar$ python3 -m venv env2
leme:Temp ar$ source env2/bin/activate
(env2) leme:Temp ar$ pip install pygments
Collecting pygments
  Using cached https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl
Installing collected packages: pygments
Successfully installed pygments-2.4.2
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env2) leme:Temp ar$ deactivate

任何想法?很奇怪!

标签: pythonpython-3.xvirtualenvpython-venv

解决方案


推荐阅读