17

Since I have a mac with a M1 chip, I couldn't get Tensorflow installed using the regular version of anaconda, therefore, I installed conda using miniforge3-MacOSX-arm64.sh instead. However now I cannot create an environment with python 2.7.

conda create --name osmEnv python=2.7

I end up with the following error,

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.

As suggested in the comments for adding a new channel (orginal question), I also tried using the anaconda channel,

conda create --name osmEnv -c anaconda python=2.7

Which resulted in the same error. Any ideas how to get python 2.7 installed.

3
  • Use -c <channel name>. E.g. conda create -c conda-forge ... Commented May 4, 2021 at 7:18
  • Is this correct conda create -c conda-forge --name osmEnv python=2.7, didnt work though Commented May 4, 2021 at 7:24
  • 1
    Are you sure that there is a compatible Python version available through Conda? Commented May 14, 2021 at 15:19

1 Answer 1

59

Not natively. Python 2.7 was sunsetted prior to release of the osx-arm64 platform, so there isn't any such build. One could try requesting such a build on the Conda Forge Python feedstock, but even if someone did that you'd still face the issue that most Python packages will also lack osx-arm64 builds for Python 2.7.

Emulate through Rosetta. Apple provides an x86_64 emulator, Rosetta 2, which will run x86_64 binaries, such as what would be installed with Conda environments using an osx-64 subdir. One can create environments with such a subdir setting with something like:

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

Just be mindful to always have the environment activated when installing any additional packages. Rosetta should automatically kick in when launching python with such an environment activated.

Sign up to request clarification or add additional context in comments.

Just tested on M1 pro, seems to work decently!
@Hiram thanks for confirming. Please let me know if there's anything that could be clarified here.
Success create environment py27 with python=2.7, but when switch to py27, python --version still shows 3.9.7.
@Harrison Ensure that your environment is activated correctly (e.g., check PATH before and after). A more robust test that is not dependent on shell state would be conda run -n py27 python --version.
Sad that Python 2.7 doesn't have at least one legacy build on conda-forge. Nobody is looking for updates or support or new packages, just for a reproducible legacy environment available from a freely accessible channel.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.