简体   繁体   English

创建Python虚拟环境后pyvenv.cfg的用途是什么?

[英]What is the purpose of pyvenv.cfg after the creation of a Python virtual environment?

When I create a virtual environment in Python on Windows cmd, in the virtual environment folder, the following files appear:当我在 Windows cmd 上的 Python 中创建虚拟环境时,在虚拟环境文件夹中,出现以下文件:

  • Include包括
  • Lib
  • Scripts脚本
  • pyvenv.cfg pyvenv.cfg

What is the goal of pyvenv.cfg creation? pyvenv.cfg 创建的目标是什么? Can I use it in any way?我可以以任何方式使用它吗?

pyvenv.cfg is a configuration file that stores information about the virtual environment such as pyvenv.cfg是一个配置文件,其中存储了有关虚拟环境的信息,例如

  • standard libraries path标准库路径
  • Python version蟒蛇版本
  • interpreter version解释器版本
  • virtual env flags虚拟环境标志
  • or any other venv configs或任何其他 venv 配置

If print content of pyvenv.cfg如果打印pyvenv.cfg的内容

$ cat myenv/pyvenv.cfg
home = /usr/bin
include-system-site-packages = false
version = 3.8.5

This is a sample output of the pyvenv.cfg file.这是pyvenv.cfg文件的示例输出。

Cheers!干杯!

One of the problems though is that the "version=" information lies.但问题之一是“版本=”信息存在。 For example, in a recent.venv I created for a project it says:例如,在我为一个项目创建的 recent.venv 中,它说:

home = /Library/Frameworks/Python.framework/Versions/3.10/bin
include-system-site-packages = false
version = 3.10.4

however, when I just installed python 3.10.6, it updates the base 3.10, and now the version info is incorrect.但是,当我刚安装 python 3.10.6 时,它更新了基础 3.10,现在版本信息不正确。 As I am just doing tutorials, I am happy that the environment now has the latest version, but I don't see the point of having incorrect version information in the cfg file.由于我只是在做教程,我很高兴环境现在拥有最新版本,但我看不出 cfg 文件中的版本信息不正确的意义。

In looking at the venv/bin folder I see symlinks of python, python3, and python3.10 commands.在查看 venv/bin 文件夹时,我看到了 python、python3 和 python3.10 命令的符号链接。

It appears that by default on my system the venv is using symlinks instead of copies of the python binaries, which is fine, but if using symlinks, the cfg should not list the subversion number.看来,默认情况下,在我的系统上,venv 使用符号链接而不是 python 二进制文件的副本,这很好,但如果使用符号链接,cfg 不应列出颠覆号。 We can specify that the venv command create copies instead, but my problem is with the incorrect info on the.cfg file.我们可以指定 venv 命令创建副本,但我的问题是 .cfg 文件上的信息不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 windows 上安装 Python 后,Python pyvenv.cfg not found 错误 - Python pyvenv.cfg not found error after installing Python on windows 没有 pyvenv.cfg 文件 - No pyvenv.cfg file python 诗歌安装在 Windows 10 上失败 - 没有 pyvenv.cfg 文件 - python poetry installation failed on Windows 10 - no pyvenv.cfg file 这个“pyvenv.cfg”文件在哪里? - Where does this “pyvenv.cfg” file exist? PermissionError:[Errno 1] 不允许操作:'/Users/<local_path> /venv/pyvenv.cfg'</local_path> - PermissionError: [Errno 1] Operation not permitted: '/Users/<local_path>/venv/pyvenv.cfg' Pyvenv 无法创建虚拟环境 - Pyvenv cannot create virtual environment 创建虚拟环境后“include”文件夹的作用是什么? - What is the purpose of the “include” folder after creating a virtual environment? 在没有互联网访问权限的 rhel 6 上的虚拟 python 环境(virtualenv 或 pyvenv)中安装 rpm 包 - installing rpm packages inside of a virtual python environment (virtualenv or pyvenv) on rhel 6 with no internet access 我是否使用`pyvenv`或`virtualenv`来创建虚拟环境? - Do I use `pyvenv` or `virtualenv` for creating a virtual environment? 删除先前的环境目录后,Conda无法完全创建虚拟环境 - Conda incomplete creation of virtual environment after deleting previous environment directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM