我最近在安装Python 3.8.0和Python 3.7.4。
我有一些虚拟环境(使用python -m venv <directory>
基于v3.7.4创建的虚拟环境。如何更新它们以使用v3.8.0?
我需要创建一个新的虚拟环境并重新安装依赖项,脚本等吗?
注意:已有一些有关较旧的软件包/工具的常见问题解答(例如this)virtualenv
。我要特别询问的是新的内置venv
模块,它是v3.3以来Python的标准内置模块,与有所不同virtualenv
。
我猜您正在寻找的是--upgrade
参数。
python -m venv --help
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
[--upgrade] [--without-pip] [--prompt PROMPT]
ENV_DIR [ENV_DIR ...]
Creates virtual Python environments in one or more target directories.
positional arguments:
ENV_DIR A directory to create the environment in.
optional arguments:
-h, --help show this help message and exit
--system-site-packages
Give the virtual environment access to the system
site-packages dir.
--symlinks Try to use symlinks rather than copies, when symlinks
are not the default for the platform.
--copies Try to use copies rather than symlinks, even when
symlinks are the default for the platform.
--clear Delete the contents of the environment directory if it
already exists, before environment creation.
--upgrade Upgrade the environment directory to use this version
of Python, assuming Python has been upgraded in-place.
--without-pip Skips installing or upgrading pip in the virtual
environment (pip is bootstrapped by default)
--prompt PROMPT Provides an alternative prompt prefix for this
environment.
您需要使用目标python版本运行它,例如在这种情况下:
python3.8 -m venv --upgrade <path_to_dir>
假设python3.8是python 3.8.0可执行文件的名称。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句