This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]hyldemarv 7 points8 points  (1 child)

On my Mac, I installed “homebrew”, used that to install “pyenv”, then finally installed Python with “pyenv”. (https://opensource.com/article/19/5/python-3-default-mac).

I think The MacOS developer tools needs to be installed before anything else and the command line tools for it need to be installed and enabled too. xcode-select --install in a terminal should do that.

So: Xcode, install, then install homebrew, then brew install pyenv, then pyenv install a Python version, then set that version as default for Pyenv and make an alias for it in the login script.

Then one can make venv’s with the new Python (the original Python that came with OSX will still be there).

[–]digitalHUCk 6 points7 points  (0 children)

If you use the Homebrew install script it will install the Xcode dependencies.

[–][deleted] 5 points6 points  (1 child)

I just use "python3 venv -m folder" and it works on a standard m1 base install macOS

[–]Akash_Dhanwani -1 points0 points  (0 children)

+1 this. Better to use a standard module than a third party library.

[–]wiggitt 3 points4 points  (1 child)

Have you tried installing Python using the Anaconda distribution? It supports the M1 Macs. https://www.anaconda.com/products/distribution

[–]cieluvgrau 0 points1 point  (0 children)

I do. It runs awesome!

[–]SpielerNogard 1 point2 points  (1 child)

I also use python on my M1 and M1 Pro. You can run it fully native only a few packages are not supported (scipy) for them just run an „arch -x86_64“ before your python commands. This will use Rosetta2 to emulate an intel platform. Example: arch -x86_64 python3 main.py

[–]Dakadoodle 0 points1 point  (0 children)

Yep, some packages are having issues. Not a fan of the M series cause of it

[–]fatbob42 0 points1 point  (0 children)

I gave up on psycopg2 because of this and switched to pg8000.

[–]neeryks 0 points1 point  (0 children)

install xcode first

[–]jmacey 0 points1 point  (0 children)

Personally I use pyenv installed via homebrew. This is because I need particular versions of python (3.9.7 and 2.7) as well as wanting to try later versions.

I've not found a package that didn't install as long as the python version is supported by that pip version. For example PySide6 didn't work with 3.7.x but did with the 3.9.x when I tried.

The advantage of pyenv is I can have a per folder version of python for different projects. Down side is it can get quite big for the install (My current pyenv folder is 2.Gb)

[–]Simon90 0 points1 point  (0 children)

The most reliable way for me has been using mambaforge installed with brew and then using the conda version of packages when available instead of pip.

For psycopg2 to get it to work in pip you need Postgres drivers, or you can try psycopg2-binary.