问题描述
由于我有一台带有 M1 芯片的 Mac,我无法使用常规版本的 anaconda 安装 Tensorflow,因此,我使用 miniforge3-MacOSX-arm64.sh
安装了 conda。但是现在我无法使用 python 2.7 创建环境。
conda create --name osmEnv python=2.7
我最终遇到以下错误,
PackagesNotFoundError: The following packages are not available from current channels:
- python=2.7
Current channels:
- https://conda.anaconda.org/conda-forge/osx-arm64
- https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for,navigate to
https://anaconda.org
and use the search bar at the top of the page.
正如添加新频道的评论中所建议的(原始问题),我也尝试使用 anaconda 频道,
conda create --name osmEnv -c anaconda python=2.7
这导致了同样的错误。任何关于如何安装 python 2.7 的想法。
解决方法
不是本机。Python 2.7 在 osx-arm64 平台发布之前就已弃用,因此没有任何此类构建。您可以尝试在 the Conda Forge Python feedstock 上请求这样的构建,但即使有人这样做了,您仍然会面临这样一个问题,即大多数 Python 包也将缺少用于 Python 2.7 的 osx-arm64 构建。
可能通过 Rosetta。相反,可以尝试使用 Apple 的 x86_64 模拟器 Rosetta 2 来运行带有 osx-64 子目录的 Conda 环境。这可能很冒险(未经测试 - 有人需要给我买 M1 :),但可以创建一个基于其他架构的环境:
CONDA_SUBDIR=osx-64 conda create -n py27 python=2.7 # include other packages here
# ensure that future package installs in this env stick to 'osx-64'
conda activate py27
conda config --env --set subdir osx-64
然后我认为您必须启动 a terminal with Rosetta,然后从那里启动 Python。类似的东西。