gpt4 book ai didi

python - Msys2:维护两个 python 安装

转载 作者:行者123 更新时间:2023-12-05 06:18:08 28 4
gpt4 key购买 nike

我在 Win 10 下使用 Msys2 portable。我有 2 个 python 3.8 安装。最初的问题是问是否是这样。我现在确定是,所以暂时我想处理他们的维护。

我还发布了另一个相关问题 Msys2: readline in two python installations

我将在下面发布有关两者的信息。

我的问题是:

  1. 它们会互相干扰吗?如果是这样,我应该处理哪些步骤/配置? (PYTHONPATHsite-packages 等)

  2. 移除其中任何一个而不破坏另一个是否安全?下面的依赖项在我看来这意味着没有风险,但我不确定是否有足够的信息来回答这个问题。

  3. 最好保留哪一个?我的意思是通过 Eclipse CDT 使用 numpypandas、gcc-toolchain 和调试器,以及许多其他包。

PS1:这是对 python2 的补充,同样的问题也适用。

PS2:我觉得奇怪的是,可用的子版本并不完全相同,即使版本都是 3.8.2。

PS3:这两条 python 很可能是this "play"主角的升级版, python 3.8 (3.8.1 before) 升级到 mingw-w64-x86_64-python 3.8.2-2 和 python 3.7 升级到 python 3.8.2-1.



提供python的包

$ pacman -Sl | grep "python " | grep "installed"
mingw64 mingw-w64-x86_64-python 3.8.2-2 [installed]
msys python 3.8.2-1 [installed]

每个(依赖项等)的附加信息

$ pacman -Qi mingw-w64-x86_64-python
Name : mingw-w64-x86_64-python
Version : 3.8.2-2
Description : A high-level scripting language (mingw-w64)
Architecture : any
URL : https://www.python.org/
Licenses : PSF
Groups : None
Provides : mingw-w64-x86_64-python3=3.8.2
Depends On : mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-expat mingw-w64-x86_64-bzip2 mingw-w64-x86_64-libffi mingw-w64-x86_64-mpdecimal
mingw-w64-x86_64-ncurses mingw-w64-x86_64-openssl mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-tcl mingw-w64-x86_64-tk mingw-w64-x86_64-zlib
mingw-w64-x86_64-xz
Optional Deps : None
Required By : mingw-w64-x86_64-gdb mingw-w64-x86_64-glib2 mingw-w64-x86_64-gtest mingw-w64-x86_64-mono mingw-w64-x86_64-postgresql
mingw-w64-x86_64-python-apipkg mingw-w64-x86_64-python-appdirs mingw-w64-x86_64-python-atomicwrites mingw-w64-x86_64-python-attrs
mingw-w64-x86_64-python-cairo mingw-w64-x86_64-python-colorama mingw-w64-x86_64-python-contextlib2 mingw-w64-x86_64-python-cycler
mingw-w64-x86_64-python-defusedxml mingw-w64-x86_64-python-imagesize mingw-w64-x86_64-python-importlib-metadata mingw-w64-x86_64-python-iniconfig
mingw-w64-x86_64-python-jdcal mingw-w64-x86_64-python-kiwisolver mingw-w64-x86_64-python-lxml mingw-w64-x86_64-python-more-itertools
mingw-w64-x86_64-python-numpy mingw-w64-x86_64-python-olefile mingw-w64-x86_64-python-ordered-set mingw-w64-x86_64-python-packaging
mingw-w64-x86_64-python-pathlib2 mingw-w64-x86_64-python-pillow mingw-w64-x86_64-python-pluggy mingw-w64-x86_64-python-py
mingw-w64-x86_64-python-pyparsing mingw-w64-x86_64-python-pytest mingw-w64-x86_64-python-pytz mingw-w64-x86_64-python-scandir
mingw-w64-x86_64-python-seaborn mingw-w64-x86_64-python-setuptools mingw-w64-x86_64-python-sip mingw-w64-x86_64-python-six
mingw-w64-x86_64-python-wcwidth mingw-w64-x86_64-python-zipp mingw-w64-x86_64-vapoursynth
Optional For : mingw-w64-x86_64-vtk
Conflicts With : mingw-w64-x86_64-python3 mingw-w64-x86_64-python2<2.7.16-7
Replaces : mingw-w64-x86_64-python3
Installed Size : 112.87 MiB
Packager : Alexey Pavlov <alexpux@gmail.com>
Build Date : Thu, Apr 9, 2020 10:17:39 AM
Install Date : Wed, Apr 22, 2020 10:04:36 AM
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature

$ pacman -Qi python
Name : python
Version : 3.8.2-1
Description : Next generation of the python high-level scripting language
Architecture : i686
URL : https://www.python.org/
Licenses : custom
Groups : None
Provides : python3
Depends On : libbz2 libexpat libffi liblzma ncurses libopenssl libreadline mpdecimal libsqlite zlib
Optional Deps : None
Required By : gdb python3-appdirs python3-attrs python3-pip python3-pyparsing python3-six scons
Optional For : None
Conflicts With : None
Replaces : python3
Installed Size : 47.27 MiB
Packager : Alexey Pavlov <alexpux@gmail.com>
Build Date : Thu, Apr 16, 2020 12:31:48 PM
Install Date : Wed, Apr 22, 2020 10:15:54 AM
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature

提供python2的包

$ pacman -Sl | grep "python2 " | grep "installed"
mingw64 mingw-w64-x86_64-python2 2.7.18-1 [installed: 2.7.17-2]
msys python2 2.7.18-1 [installed: 2.7.17-1]

最佳答案

我在 MSYS2 shell(版本 2 + 3)中使用 2 个不同的 Python 版本。

我的做法是:

  • Python 路径均未包含在 PATH 中环境变量,所以如果某些东西需要 Python,它就会失败。
  • 当需要 Python 时,我会在前面加上 PATH=<python_path>:$PATH到需要它的命令(例如 PATH=/D/Prog/Python/WinPython-64bit-2.7.13.1Zero/python-2.7.13.amd64:$PATH make ),或者如果命令支持在环境中设置 PYTHON,我会在前面加上 PYTHON=<python_path>/python.exe在命令之前。在某些情况下 Makefileconfigure接受 PYTHON变量也可以附加 PYTHON=<python_path>/python.exe命令之后。
  • 如果 Python 想要加载某些模块,可能还需要设置 PYTHONPATH变量(例如 PYTHONPATH=<python_path>/Lib/site-packages )

这对我来说效果很好,并且总是迫使我选择我使用的 Python。

关于python - Msys2:维护两个 python 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61378854/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com