# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2025, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # python-doc bot, 2025 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2025-09-22 21:56+0000\n" "PO-Revision-Date: 2025-09-22 17:56+0000\n" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../tutorial/venv.rst:6 msgid "Virtual Environments and Packages" msgstr "虚拟环境和包" #: ../../tutorial/venv.rst:9 msgid "Introduction" msgstr "概述" #: ../../tutorial/venv.rst:11 msgid "" "Python applications will often use packages and modules that don't come as " "part of the standard library. Applications will sometimes need a specific " "version of a library, because the application may require that a particular " "bug has been fixed or the application may be written using an obsolete " "version of the library's interface." msgstr "" "Python应用程序通常会使用不在标准库内的软件包和模块。应用程序有时需要特定版本的库,因为应用程序可能需要修复特定的错误,或者可以使用库的过时版本的接口编写应用程序。" #: ../../tutorial/venv.rst:17 msgid "" "This means it may not be possible for one Python installation to meet the " "requirements of every application. If application A needs version 1.0 of a " "particular module but application B needs version 2.0, then the requirements" " are in conflict and installing either version 1.0 or 2.0 will leave one " "application unable to run." msgstr "" "这意味着一个Python安装可能无法满足每个应用程序的要求。如果应用程序A需要特定模块的1.0版本但应用程序B需要2.0版本,则需求存在冲突,安装版本1.0或2.0将导致某一个应用程序无法运行。" #: ../../tutorial/venv.rst:23 msgid "" "The solution for this problem is to create a :term:`virtual environment`, a " "self-contained directory tree that contains a Python installation for a " "particular version of Python, plus a number of additional packages." msgstr "" "这个问题的解决方案是创建一个 :term:`virtual environment`,一个目录树,其中安装有特定Python版本,以及许多其他包。" #: ../../tutorial/venv.rst:27 msgid "" "Different applications can then use different virtual environments. To " "resolve the earlier example of conflicting requirements, application A can " "have its own virtual environment with version 1.0 installed while " "application B has another virtual environment with version 2.0. If " "application B requires a library be upgraded to version 3.0, this will not " "affect application A's environment." msgstr "" "然后,不同的应用将可以使用不同的虚拟环境。 要解决先前需求相冲突的例子,应用程序 A 可以拥有自己的 安装了 1.0 版本的虚拟环境,而应用程序 B " "则拥有安装了 2.0 版本的另一个虚拟环境。 如果应用程序 B 要求将某个库升级到 3.0 版本,也不会影响应用程序 A 的环境。" #: ../../tutorial/venv.rst:36 msgid "Creating Virtual Environments" msgstr "创建虚拟环境" #: ../../tutorial/venv.rst:38 msgid "" "The module used to create and manage virtual environments is called " ":mod:`venv`. :mod:`venv` will usually install the most recent version of " "Python that you have available. If you have multiple versions of Python on " "your system, you can select a specific Python version by running ``python3``" " or whichever version you want." msgstr "" "用于创建和管理虚拟环境的模块称为 :mod:`venv`。:mod:`venv` 通常会安装你可用的最新版本的 Python。如果您的系统上有多个版本的" " Python,您可以通过运行 ``python3`` 或您想要的任何版本来选择特定的Python版本。" #: ../../tutorial/venv.rst:44 msgid "" "To create a virtual environment, decide upon a directory where you want to " "place it, and run the :mod:`venv` module as a script with the directory " "path::" msgstr "要创建虚拟环境,请确定要放置它的目录,并将 :mod:`venv` 模块作为脚本运行目录路径::" #: ../../tutorial/venv.rst:49 msgid "" "This will create the ``tutorial-env`` directory if it doesn't exist, and " "also create directories inside it containing a copy of the Python " "interpreter, the standard library, and various supporting files." msgstr "" #: ../../tutorial/venv.rst:53 msgid "" "A common directory location for a virtual environment is ``.venv``. This " "name keeps the directory typically hidden in your shell and thus out of the " "way while giving it a name that explains why the directory exists. It also " "prevents clashing with ``.env`` environment variable definition files that " "some tooling supports." msgstr "" "虚拟环境的常用目录位置是 ``.venv``。 这个名称通常会令该目录在你的终端中保持隐藏,从而避免需要对所在目录进行额外解释的一般名称。 " "它还能防止与某些工具所支持的 ``.env`` 环境变量定义文件发生冲突。" #: ../../tutorial/venv.rst:59 msgid "Once you've created a virtual environment, you may activate it." msgstr "创建虚拟环境后,您可以激活它。" #: ../../tutorial/venv.rst:61 msgid "On Windows, run::" msgstr "在Windows上,运行::" #: ../../tutorial/venv.rst:65 msgid "On Unix or MacOS, run::" msgstr "在Unix或MacOS上,运行::" #: ../../tutorial/venv.rst:69 msgid "" "(This script is written for the bash shell. If you use the :program:`csh` " "or :program:`fish` shells, there are alternate ``activate.csh`` and " "``activate.fish`` scripts you should use instead.)" msgstr "" "(这个脚本是为bash shell编写的。如果你使用 :program:`csh` 或 :program:`fish` shell,你应该改用 " "``activate.csh`` 或 ``activate.fish`` 脚本。)" #: ../../tutorial/venv.rst:74 msgid "" "Activating the virtual environment will change your shell's prompt to show " "what virtual environment you're using, and modify the environment so that " "running ``python`` will get you that particular version and installation of " "Python. For example:" msgstr "" "激活虚拟环境将改变你所用终端的提示符,以显示你正在使用的虚拟环境,并修改环境以使 ``python`` 命令所运行的将是已安装的特定 Python " "版本。 例如:" #: ../../tutorial/venv.rst:93 msgid "Managing Packages with pip" msgstr "使用pip管理包" #: ../../tutorial/venv.rst:95 msgid "" "You can install, upgrade, and remove packages using a program called " ":program:`pip`. By default ``pip`` will install packages from the Python " "Package Index, . You can browse the Python Package Index " "by going to it in your web browser." msgstr "" #: ../../tutorial/venv.rst:100 msgid "" "``pip`` has a number of subcommands: \"install\", \"uninstall\", \"freeze\"," " etc. (Consult the :ref:`installing-index` guide for complete documentation" " for ``pip``.)" msgstr "" "``pip`` 有许多子命令: \"install\", \"uninstall\", \"freeze\" 等等。 (请在 " ":ref:`installing-index` 指南页查看完整的 ``pip`` 文档。)" #: ../../tutorial/venv.rst:104 msgid "" "You can install the latest version of a package by specifying a package's " "name:" msgstr "您可以通过指定包的名称来安装最新版本的包:" #: ../../tutorial/venv.rst:115 msgid "" "You can also install a specific version of a package by giving the package " "name followed by ``==`` and the version number:" msgstr "您还可以通过提供包名称后跟 ``==`` 和版本号来安装特定版本的包:" #: ../../tutorial/venv.rst:126 msgid "" "If you re-run this command, ``pip`` will notice that the requested version " "is already installed and do nothing. You can supply a different version " "number to get that version, or you can run ``pip install --upgrade`` to " "upgrade the package to the latest version:" msgstr "" "如果你重新运行这个命令,``pip`` 会注意到已经安装了所请求的版本并且什么都不做。您可以提供不同的版本号来获取该版本,或者您可以运行 ``pip " "install --upgrade`` 将软件包升级到最新版本:" #: ../../tutorial/venv.rst:141 msgid "" "``pip uninstall`` followed by one or more package names will remove the " "packages from the virtual environment." msgstr "``pip uninstall`` 后跟一个或多个包名称将从虚拟环境中删除包。" #: ../../tutorial/venv.rst:144 msgid "``pip show`` will display information about a particular package:" msgstr "``pip show`` 将显示有关特定包的信息:" #: ../../tutorial/venv.rst:161 msgid "" "``pip list`` will display all of the packages installed in the virtual " "environment:" msgstr "``pip list`` 将显示虚拟环境中安装的所有软件包:" #: ../../tutorial/venv.rst:173 msgid "" "``pip freeze`` will produce a similar list of the installed packages, but " "the output uses the format that ``pip install`` expects. A common convention" " is to put this list in a ``requirements.txt`` file:" msgstr "" "`pip freeze`` 将生成一个类似的已安装包列表,但输出使用 ``pip install`` 期望的格式。一个常见的约定是将此列表放在 " "``requirements.txt`` 文件中:" #: ../../tutorial/venv.rst:185 msgid "" "The ``requirements.txt`` can then be committed to version control and " "shipped as part of an application. Users can then install all the necessary" " packages with ``install -r``:" msgstr "" "然后可以将 ``requirements.txt`` 提交给版本控制并作为应用程序的一部分提供。然后用户可以使用 ``install -r`` " "安装所有必需的包:" #: ../../tutorial/venv.rst:202 msgid "" "``pip`` has many more options. Consult the :ref:`installing-index` guide " "for complete documentation for ``pip``. When you've written a package and " "want to make it available on the Python Package Index, consult the " ":ref:`distributing-index` guide." msgstr "" "``pip`` 有更多选择。有关 ``pip`` 的完整文档,请参阅 :ref:`installing-index` 指南。当您编写一个包并希望在 " "Python 包索引中使它可用时,请参考 :ref:`distributing-index` 指南。"