Python Forum
How to install Python on a Mac
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to install Python on a Mac
#1
Hi there,

I've been trying to install Python on my Mac for quite sometime - without success.

First, I downloaded the official file from python.org and installed it.

Then, I learned about the various versions and the issues related to that and came across this guide ("doing it right"), installed homebrew, python and pyenv. Worked out fine, I could install the modules I needed, however, I could not get IDLE to run because of this error message: "IDLE can't import Tkinter".

I learned about the issues related to that and gave up the idea of installing things via homebrew. Went back to the official download from python.org, installed it, IDLE is there, however, now I am wondering how do I install the modules I need to work with this particular version.

Any ideas? Any thoughts? Any advice?

Thank you.
Reply
#2
What was wrong with Homebrew?

You can install Python modules with pip. In order to find out which Python version is used with pip enter into terminal:

which pip

It will return path of Python associate with pip.

You can also use conda or miniconda.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
(Sep-26-2020, 08:32 PM)perfringo Wrote: What was wrong with Homebrew?

Idle doesn't work on Mac.
Reply
#4
Is it so? I don't use IDLE but:

brew list | grep python

resulted:

ipython
[email protected]

Then ⌘+space and entering IDLE will open it with no problems (Python version 3.8 in IDLE).
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#5
Hmmm ...

brew list | grep python -> not sure if something happens, no error message, nothing else, just a new line
ipython -> zsh: command not found: ipython
[email protected] -> zsh: command not found: [email protected] -> zsh: command not found: [email protected]

Don't know whats wrong. I have to admit though that my environment is now a bit messed up because I tried several different things which I might not have been able to completely roll back. Is there a way to get to a "clean" environment first? Also, I have PYENV installed. Does it impact what you proposed above?

Thanks
Reply
#6
This works (at least for me) if Python is installed with brew.brew list lists all installed formulaes (from man):

Quote:list:
List all installed formulae.


If there is no Python in the list then it is not installed with brew.

If you use brew extensively then populated list can be quite long so just pipe it into grep to get only results you are interested in. I use bash but it should work with zsh as well.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#7
Why the heck is it that difficult on get started with Pyhton on a Mac?

Now that I got Idle for whatever reason somehow working, I face a SSL problem:

Tried to use the urllib.request library and immediately get the following error message:

"urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>"

What can I do?
Reply
#8
(Sep-27-2020, 06:56 AM)BlueBlue Wrote: I have PYENV installed. Does it impact what you proposed above?
Then you can use pyenv,look at pyenv Simple Python Version Management.
So have done setup for pyenv correct?
For Mac wiki.

Then is my last post,update pyenv and now the last version is pyenv install 3.8.5.
Set it as global(system wide) then use it.
Reply
#9
(Oct-03-2020, 07:32 AM)BlueBlue Wrote: Why the heck is it that difficult on get started with Pyhton on a Mac?

It's not difficult to get started with Python on MacOS. Just open terminal, type python and there you are. Of course, this version is probably not the version you would like to work with but anyway - get started is as simple as entering 'python'.

If you are not uncomfortable with terminal and profile/rc files you should consider getting familiar with them. You need general understanding sooner than later. If your intentions are serious then you could consider alternatives to IDLE. There are several options, I would personally recommend VS Code. There is nice tutorial written by snippsat VS Code from the start

There are free options to get started with Python without any installation whatsoever. To name a few: repl.it, Google Colab (Jupyter Notebook) etc.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#10
(Oct-03-2020, 09:17 AM)perfringo Wrote:
(Oct-03-2020, 07:32 AM)BlueBlue Wrote: Why the heck is it that difficult on get started with Pyhton on a Mac?

It's not difficult to get started with Python on MacOS. Just open terminal, type python and there you are. Of course, this version is probably not the version you would like to work with but anyway - get started is as simple as entering 'python'.

If you are not uncomfortable with terminal and profile/rc files you should consider getting familiar with them. You need general understanding sooner than later. If your intentions are serious then you could consider alternatives to IDLE. There are several options, I would personally recommend VS Code. There is nice tutorial written by snippsat VS Code from the start

There are free options to get started with Python without any installation whatsoever. To name a few: repl.it, Google Colab (Jupyter Notebook) etc.

Thank you @perfringo 

You are right, I am definitely lacking knowledge in some areas you mentioned. However, and this is what I am referring to, on a Win10 PC I download the official Python distribution, install it, have IDLE and don't have to worry about anything. On my Raspberry Pi this is the same. On a Mac, you need to find your way around the pre-installed Python, download the official distribution, try to start Python and get a "Your Python may not be configured for Tk. **". This is ridiculous and this is what I mean. When googling for solutions you get the advice to compile it on your own and stuff like that - each step of it is for somebody who doesn't speak Terminal natively a nightmare.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020