Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
I would like to learn Python. Does anybody know how to install the latest Python version natively on the MacBook M1?

1. I want to install just python the latest version, not any of the IDE's like Anaconda, Pycharm etc,
2. I want to install the libraries for Tensor Flow.
3. I want to install Visual Code.

If you know how to do this to run natively, please share the instructions... It will be appreciated.

Thank You!!!
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
I would like to learn Python. Does anybody know how to install the latest Python version natively on the MacBook M1?

1. I want to install just python the latest version, not any of the IDE's like Anaconda, Pycharm etc,
2. I want to install the libraries for Tensor Flow.
3. I want to install Visual Code.

If you know how to do this to run natively, please share the instructions... It will be appreciated.

Thank You!!!
Use a package manager. For home-brew, which is the one I use it's as simple as

brew install python visual-studio-code

That will install both Python and Visual Studio Code - You can also install a specific version of Python like
brew install python@3.8

After installing Python through brew you will have the pip package manager for Python so you can use pip3 install to install Python libraries.
 

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
That was fast...

So the only way to install natively without Rosetta is by Brew?

I did iPhone programming with Objective-C and Swift many years ago, I want to recover those powers again for that reason I did a clean install to setup the machine for programming again.

Do you know how to setup Xcode for using the Tensorflow libraries?

By the way, what is your opinion about SwiftUI? Do you recommend to learn SwiftUI or continue with Swift?
In my ignorant opinion it seams that SwiftUI is the future, what is your perspective about it.

It seams to me that for playing with Machine Learning I have to know some Python for that reason I will dedicate 4 or 5 months to just learn Python and refresh my Swift programming, getting and sharpening the tools before the dive, but I am in the dilemma between SwiftUI or Swift.

Any information that you provide will be appreciated.

and again, thanks for your fast response.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
That was fast...

So the only way to install natively without Rosetta is by Brew?

I did iPhone programming with Objective-C and Swift many years ago, I want to recover those powers again for that reason I did a clean install to setup the machine for programming again.

Do you know how to setup Xcode for using the Tensorflow libraries?

By the way, what is your opinion about SwiftUI? Do you recommend to learn SwiftUI or continue with Swift?
In my ignorant opinion it seams that SwiftUI is the future, what is your perspective about it.

It seams to me that for playing with Machine Learning I have to know some Python for that reason I will dedicate 4 or 5 months to just learn Python and refresh my Swift programming, getting and sharpening the tools before the dive, but I am in the dilemma between SwiftUI or Swift.

Any information that you provide will be appreciated.

and again, thanks for your fast response.

I get email notifications for the developer forums :p

It is not the only way, no, but it is the easiest, arguably fastest and most manageable way. The Xcode installed one is also a universal build but Xcode wants to install Rosetta for Universal/Rosetta testing support.

It's funny, I think of Swift as still a fairly new and recent language :p

I've never used Tensorflow so can't speak to using it with Xcode.

Python is definitely very dominant in the ML field. You can use CoreML without needing to touch Python and use CreateML to make some models without even needing to code the models themselves, but yeah a lot of machine learning tools target Python.

I would not go as far as saying SwiftUI *is the future*. But SwiftUI is part of the future. I don't ever see AppKit/UIKit being entirely replaced by SwiftUI and SwiftUI presently also builds on top of those, but I do see a lot of UIs being made with just SwiftUI and whole applications for that matter. But I think there will always be a place for AppKit and UIKit even if the majority of codebases' UI may be done with SwiftUI.

I don't know what you mean by "the dilemma between SwiftUI and Swift"
 

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
I don't know what you mean by "the dilemma between SwiftUI and Swift"
Thank you for you valuable opinion, I really appreciate it.


Making apps with SwiftUI is different from just Swift. For example SwiftUI does not have the storyboard to drag and drop views and controls. In SwiftUI with minimum code a Table View can be created. But correctly speaking I should have use the word Framework: Appkit or SwiftUI.

Rewording: "the dilemma between AppKit or SwiftUI"

As I said, I took a long break from coding and now everything has changed.
 

casperes1996

macrumors 604
Jan 26, 2014
7,593
5,764
Horsens, Denmark
Thank you for you valuable opinion, I really appreciate it.


Making apps with SwiftUI is different from just Swift. For example SwiftUI does not have the storyboard to drag and drop views and controls. In SwiftUI with minimum code a Table View can be created. But correctly speaking I should have use the word Framework: Appkit or SwiftUI.

Rewording: "the dilemma between AppKit or SwiftUI"

As I said, I took a long break from coding and now everything has changed.

Ah yess, I see.

Well, it might help you to know that you're not strictly speaking limited to one or the other. While the templates Xcode provides sets you up for either or, you can mix and match SwiftUI and UIKit/AppKit in the same app, and in fact many apps today do so, since there are still some holes in SwiftUI and also long-lived codebases with a lot of AppKit that's slowly moving towards SwiftUII.

This here is the key to putting UIKit views into SwiftUI and a similar one exists for NSViews
 
  • Like
Reactions: TokMok3

Lihp8270

macrumors 65816
Dec 31, 2016
1,139
1,601
Fwiw you really should be using virtual environments.

You will likely need different versions of Python, and different library versions for compatibility etc. using virtual environments allows you to run multiple different versions unique for each project.

It also separates your Python development from the Python that already exists for the system.
 
  • Like
Reactions: TokMok3

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
Ah yess, I see.

Well, it might help you to know that you're not strictly speaking limited to one or the other. While the templates Xcode provides sets you up for either or, you can mix and match SwiftUI and UIKit/AppKit in the same app, and in fact many apps today do so, since there are still some holes in SwiftUI and also long-lived codebases with a lot of AppKit that's slowly moving towards SwiftUII.

This here is the key to putting UIKit views into SwiftUI and a similar one exists for NSViews
I was wondering if it was possible to mix SwiftUI with Appkit. That link that you provided answered that question that I had. Thank you so much. Now I have a cleared road to follow!


Yesterday I setup this M1 with Conda, Python and Tensorflow, now just do a refresh of Swift, learn SwiftUI and read a Python book for the next 3 or 4 months to learn the fundamentals and what it can be done.
 
  • Like
Reactions: casperes1996

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
Fwiw you really should be using virtual environments.

You will likely need different versions of Python, and different library versions for compatibility etc. using virtual environments allows you to run multiple different versions unique for each project.

It also separates your Python development from the Python that already exists for the system.
Hi, Yesterday I installed Brew, Conda, Jupiter Notebook, Tensorflow, Metal and many other libraries and used Conda to create an environment for that. Never used all these software before, but I have the strong will to learn, specially this things of creating, activating and deactivating environments. At this moment everything is setup and ready to code in Python using Jupiter Notebook.

I would like to use Visual Code instead of Jupiter Notebooks in another environment just for learning Python separated from the environment that is ready for Machine Learning. I have Brew installed. Do you know how to do that?
 

Lihp8270

macrumors 65816
Dec 31, 2016
1,139
1,601
Hi, Yesterday I installed Brew, Conda, Jupiter Notebook, Tensorflow, Metal and many other libraries and used Conda to create an environment for that. Never used all these software before, but I have the strong will to learn, specially this things of creating, activating and deactivating environments. At this moment everything is setup and ready to code in Python using Jupiter Notebook.

I would like to use Visual Code instead of Jupiter Notebooks in another environment just for learning Python separated from the environment that is ready for Machine Learning. I have Brew installed. Do you know how to do that?
Once you have it all installed and you install the Python plug in for VSCode it should be fairly straight forward. Once you have created your environment. You should be able to select it when you run your code in VSCode
 
  • Like
Reactions: TokMok3

TokMok3

macrumors 6502a
Original poster
Aug 22, 2015
672
422
Once you have it all installed and you install the Python plug in for VSCode it should be fairly straight forward. Once you have created your environment. You should be able to select it when you run your code in VSCode
Hello, just installed VSCODE and before running the python program to test the Machine Learning installation, I just had to select at the bottom left corner of the VSCODE the python interpreter, and I selected the Conda version and everything just works.

Thank you so much.
 

iDron

macrumors regular
Apr 6, 2010
219
252
Did you install tensorflow-metal? It allows GPU acceleration in tensorflow. However, beware that it might be slower if you are not using the GPU. This is why you should use virtual environments, as suggested above.

There is a thread discussion ML on M1 macs:
Apple Silicon deep learning performance
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.