0

I'm running Mac OS X High Sierra 10.13.6.

When I do a "brew list python" from the terminal, it shows that I have python 3.7.3 installed:

user@laptop:~$ brew list python
/usr/local/Cellar/python/3.7.3/bin/2to3
/usr/local/Cellar/python/3.7.3/bin/2to3-3.7
/usr/local/Cellar/python/3.7.3/bin/easy_install-3.7
/usr/local/Cellar/python/3.7.3/bin/idle3
/usr/local/Cellar/python/3.7.3/bin/idle3.7
/usr/local/Cellar/python/3.7.3/bin/pip3
/usr/local/Cellar/python/3.7.3/bin/pip3.7
/usr/local/Cellar/python/3.7.3/bin/pydoc3
/usr/local/Cellar/python/3.7.3/bin/pydoc3.7
/usr/local/Cellar/python/3.7.3/bin/python3
/usr/local/Cellar/python/3.7.3/bin/python3-config
/usr/local/Cellar/python/3.7.3/bin/python3.7
/usr/local/Cellar/python/3.7.3/bin/python3.7-config
/usr/local/Cellar/python/3.7.3/bin/python3.7m
/usr/local/Cellar/python/3.7.3/bin/python3.7m-config
/usr/local/Cellar/python/3.7.3/bin/pyvenv
/usr/local/Cellar/python/3.7.3/bin/pyvenv-3.7
/usr/local/Cellar/python/3.7.3/bin/wheel3
/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/ (2818 files)
/usr/local/Cellar/python/3.7.3/IDLE 3.app/Contents/ (8 files)
/usr/local/Cellar/python/3.7.3/lib/pkgconfig/ (3 files)
/usr/local/Cellar/python/3.7.3/libexec/bin/ (7 files)
/usr/local/Cellar/python/3.7.3/libexec/pip/ (701 files)
/usr/local/Cellar/python/3.7.3/libexec/setuptools/ (345 files)
/usr/local/Cellar/python/3.7.3/libexec/wheel/ (38 files)
/usr/local/Cellar/python/3.7.3/Python Launcher 3.app/Contents/ (16 files)
/usr/local/Cellar/python/3.7.3/share/man/ (2 files)
user@laptop:~$ 

... but when I do a "python3 --version", it reports Python 3.6.3:

user@laptop:~$ python3 --version
Python 3.6.3
user@laptop:~$ 

A "which python3" reports:

user@laptop:~$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
user@laptop:~$

I don't see any 3.7 Python versions at that directory:

user@laptop:/Library/Frameworks/Python.framework/Versions$ ls -alt
total 0
drwxr-xr-x   6 root  wheel   192B Nov 30  2017 ../
drwxrwxr-x  10 root  admin   320B Nov 30  2017 3.6/
drwxrwxr-x   3 root  wheel    96B Oct  3  2017 ./
user@laptop:/Library/Frameworks/Python.framework/Versions$

At one point, I installed PyCharm CE. It's an IDE, but I'm not sure if it could have installed a separate Python 3.x?

I also have Python 3.6 IDLE installed.

I would prefer to completely restore my Mac to factory defaults, but this is a work computer and is managed by our corporate team and has a bunch of installed apps. I estimate that it will take 20 hours or so to re-install and re-do everything, so a factory restore is out of the question unfortunately.

Can anyone give me some direction on how to fix this Python issue?

0

I am pretty sure that adding:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

to your .bashrc (or .zshrc or whatever shell you are using) should do the job (just remember to source it after making changes, or relaunch the terminal).

Eventually, you might wanna take a look at pyenv - a few months ago I wrote a tutorial for myself (it is available here)

|improve this answer|||||
  • Ok, I think I'm getting somewhere, but that only makes the default python use 3.7. Can I have the command "python" use the default 2.7 and have the command "python3" use python 3.7? Also, when I run a python script with the hash-bang line with "python3", I'd like it to use python3.7. – slantalpha Oct 3 '19 at 22:19
  • By default, when installing python via Homebrew, it links python3 to homebrew python 3 (so this should be 3.7) and leaves python to be the system default (which is 2.7). I suggest this stackoverflow.com/a/34124773/6441900 answer (plus removing the command from my post). Eventually, you might wanna show the result of $ echo $PATH. – SantaXL Oct 3 '19 at 23:44
  • I'll try that. Are you referring to the answer that starts with "sudo rm -rf /Library/Frameworks/Python.framework" ? – slantalpha Oct 4 '19 at 0:20
  • Yes. My guess is that homebrew python is not on top of your $PATH and removing this framework python should fix this. Eventually, you might just wanna rename the folder instead of doing sudo rm, just in case – SantaXL Oct 4 '19 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.