How can I run Python 3.9.1 natively on M1 Mac? - python-3.9

Seems to be impossible currently with Anaconda as well as with Xcode 12. Via idle, it runs via Rosetta. There seems to be no discussion of this so either I'm quite naive or maybe this will be useful to others as well.
Python says: "As of 3.9.1, Python now fully supports building and running on macOS 11.0 (Big Sur) and on Apple Silicon Macs (based on the ARM64 architecture). A new universal build variant, universal2, is now available to natively support both ARM64 and Intel 64 in one set of executables" https://docs.python.org/3/whatsnew/3.9.html
Please help a newbie figure out how to take advantage of his recent impulse-buy.

You can now install python 3.9.1 through multiple pathways now but the most comprehensive build environment for the full data-science suite for python at the moment (Feb 2021) on M1 ARM architecture is via miniforge.
e.g.
brew install --cask miniforge
conda init zsh
conda activate
conda install numpy scipy scikit-learn

You can now install Python 3.9.4 natively on Mac M1 (Apple Silicon). I'm using pyenv to install Python 3.7, 3.8 and 3.9 all native ARM. For example, to install 3.9.4:
$ pyenv install 3.9.4
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.4.tar.xz...
-> https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.4 to /Users/squademy/.pyenv/versions/3.9.4
For a complete guide on install pyenv and multiple Python version, you might read this article: https://squademy.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9.

I am using python3.9.4. I installed it using homebrew only.
brew install python#3.9
Also you may want to do the following to unlink and check the version number
brew unlink python3
brew link python3.9
python3 --version

I upgraded to 3.9.4
Download the Python universal installer -
https://www.python.org/downloads/mac-osx/
Note: I still could not get sudo pip install mysqlclient to install.
I had add to
update homebrew - See https://brew.sh
Add /opt/homebrew/bin to PATH in .bash_profile (don't forget to source .bash_profile)
or
Add /opt/homebrew/bin to PATH in .zprofile (don't forget to source .zprofile) if using zsh

Related

How to revert to Python3.8 on my Mac using Homebrew?

please see this question: How to default Python3.8 on my Mac using Homebrew?
I'm trying to accomplish the same thing. I brew installed python and that gave me the latest 3.9; however, I would like to use 3.8 to maintain dependencies.
When i check terminal for the version of python the result is always the macOS default of 2.7.
I've used this method above and many other methods, but I am new to homebrew and zsh and I have not found a work around.
I would encourage you to use pyenv to manage different python versions in your local.
brew install pyenv
pyenv install 3.7.9
pyenv install 3.8.6
Then you can control machine default by using pyenv global x.x.x
pyenv global 3.8.6

Install qwebengine on mac

I'm using qwebengine in my Qt5 program.
I use this command to install qt on my travis-ci env:
HOMEBREW_NO_AUTO_UPDATE=1 brew install qt5 qt5-qtwebengine --verbose; fi
However it tells me: Error: No available formula with the name "qt5-qtwebengine"
How to instaall qtwebengine properly by brew?
The fix was patched in two weeks ago and you will need to brew update before you brew install qt

Install GTK+ >= 3.16 with PyGObject bindings on MacOS 10.15

when I'm typing the command
brew install pygobject3 --with-python#2 gtk+3
I'm always getting the error message
invalid option --with-python#2
I'm getting the same error message when I want to run the gtk+3 under mac os 10.15
Namespace Gtk not available
Maybe the Version of 10.15 of MacOS the problem....
gtk+3 version 3.24.12 and pygobject3 Version 3.34.0 are installed.
Installation of homebrew for MacOS
gtk+3 version 3.24.12 and pygobject3 Version 3.34.0 are installed.
Python3.7 is installed
File "...anaconda3/envs/python37/lib/python3.7/site-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
I would like to run the program DemonEditor on MacOS 10.15 (Catalina)
to make some settings of my engima2 satellite receiver, for this I need the requirements "GTK+ >= 3.16 with PyGObject bindings".
Maybe some of the experts can help me.
Thanks very much
Since I am the author of this program, I am forced to report that since the program is designed for Linux, it will not work on MacOS without minor changes to the program itself. But still it’s possible.
DemonEditor
Тo resolve dependencies, it is enough to install as follows:
brew install gtk+3 pygobject3 adwaita-icon-theme
pip3 install requests
Upd.
I created an experimental brunch and added small changes to the program for the possibility of testing the launch in the MacOS. Perhaps not all the functionality will work (I have not tested it), but the program should start.
Gud luck!
STRIKE. It works, I can start the DemonEditor-GUI under 10.15. I have remove all packages via the
brew remove --force $(brew list)
installed the three packages again, via
brew install python3 gtk+3 pygobject3 adwaita-icon-theme
BUT. The most important step was to add the "Installation folder" of the brew packages to my python path but execute the comand
export PYTHONPATH=/usr/local/lib/python3.7/site-packages.
My assumption is, that due to fact, that I have installed an own conda-environment for python37, the site-packages have to be added to the path.
Big thanks for the help.
On my test system, I did not set any paths or environment variables! Just installed python 3 with the command:
brew install python3
Then I installed the dependencies as described above.Then I downloaded the archive from here, and in the unpacked folder of the program I simply gave the command:
./start.py
Below is the output of the commands python3 --version and brew list
Compare with your list, perhaps this will somehow help identify the missing components.
python3 --version
Python 3.7.4
brew list
adwaita-icon-theme libepoxy
atk libffi
cairo libpng
fontconfig librsvg
freetype libtiff
fribidi lzo
gdbm openssl#1.1
gdk-pixbuf pango
gettext pcre
glib pixman
gobject-introspection pkg-config
graphite2 py2cairo
gsettings-desktop-schemas py3cairo
gtk+3 pygobject3
harfbuzz python
hicolor-icon-theme python#2
icu4c readline
jpeg sqlite
libcroco xz
Upd. For the experiment, I removed all my packages with the command:
brew remove --force $(brew list)
Then again installed by commands as described above
brew install python3 gtk+3 pygobject3 adwaita-icon-theme
Working!

how to install opencv and run first program in anaconda3 5.0.0 python 3.6.2 version?

I tried using
pip install opencv-python
It says to not break the installation rules and that I should use the conda command. How to install opencv and run first program on it in anaconda3 5.0.0 and python 3.6.2?
Ideall you shouldn't mix conda installed and pip installed packages - it confuses the dependencies when it comes to updates. Although you can use pip install opencv-python and opencv will work perfectly well within anaconda.
Instead you need to select opencv3 (assuming you want v3) from a specific repository
conda install -c menpo opencv3
ps. I don't know why it isn't included as standard and why have to know/search for the specific repository!

Update Software Version in Anaconda

I have installed python and many other useful tools on my Ubuntu 14.04 using Anaconda. I installed pysam (htslib interface for python) using
conda install pysam
However this installs the old version (0.6). The current version is 0.8.4. How can I install that version using conda. I don't want to use pip install pysam because I read somewhere it might cause problems.
Thanks.
Anaconda only provides version 0.6. You can install from binstar with:
conda install -c https://conda.anaconda.org/uhlitz pysam
This should give you version 0.8.3 for linux64. Other channels are also available.

Resources