Install the python 3.9.x M1 version in a virtual environment

5.2k views Asked by At

I am using an M1 mac and I am using a conda environment with python 3.8.8.

I tried to update with 'conda update python' but 3.8.8 is the latest version I can get and it is running on Rosetta 2.

I would like to install the latest 3.9.x for BigSur (so it can run natively) to the conda env (or any env).

I tried to download the python 3.9.4 universal version installer but I do not know how to put it in an virtual environment.

Thanks!

2

There are 2 answers

1
AKX On

Virtualenvs are interpreter-specific – you set up a virtualenv that uses a given interpreter version.

If you've installed Python 3.9.4 from somewhere, you can then use python3.9 -m venv some_venv to create a virtualenv that uses that interpreter. (Assuming, of course, that that python3.9 is on the path and is indeed the correct interpreter.)

(You can also python3.9 -m pip install virtualenv to install the virtualenv package, which is faster than the stock venv.)

conda is a package manager unto its own, and its environments are not to be confused with regular Python virtualenvs.

1
Prabhat Kumar Sahu On

I installed miniforge by

brew install --cask miniforge

and created a virtual env using conda and I was able to install pandas with python 3.9.1

Here's my log

❯ python3
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:00:30)
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
[1]  + 36380 suspended  python3
❯ pip3 install pandas
Collecting pandas
  Using cached pandas-1.2.4-cp39-cp39-macosx_11_0_arm64.whl
Collecting python-dateutil>=2.7.3
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pytz>=2017.3
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting numpy>=1.16.5
  Using cached numpy-1.20.2-cp39-cp39-macosx_11_0_arm64.whl
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.2 pandas-1.2.4 python-dateutil-2.8.1 pytz-2021.1 six-1.15.0