Categories Python Tags Django 2.2.x, macOS Mojave, Python 3.7.x, Python 3.x, Visual Studio Code Leave a comment How to copy a file in Python? Oct 3, 2019 Oct 3, 2019 by Beaulin Twinkle.
- How to install Command Line Tools, CLT, and the Homebrew package manager on macOS Mojave. Demo of using Homebrew to install Python 3 on macOS Mojave: https://youtu.be.
- However, the issue is most modern macOS versions come with rather with Python 2.7.x installed and not the newer, modern version like Python 3.6.5 or Python 3.7.2 (which is the most up-to-date version right now). This short guide is written to show you how to properly install Python 3 on a Mac OS X computer.
Question or issue on macOS:
I installed python2.x and python3.x using homebrew and the executable python paths are listed below:
It’s quite too long and not so clean to write a shebang in a python code to make it runnable on Terminal:
I prefer
Python 3 Mac Os Mojave Installer
My issue here is, how can I correcly move or reinstall python on macOS to /usr/bin such as /usr/bin/python OR /usr/bin/python3 Instead of
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
How to solve this problem?
Solution no. 1:
This is NOT possible on Mac OS X El Capitan anymore as from then on System Integrity Protection prevents that. More info in Cannot create a symlink inside of /usr/bin even as sudo
Solution no. 2:
Create a symbolic link in
/usr/bin/
Open terminal and do:
You can now do what you wanted to do.
Edit: Unfortunately as you can read from the other answers, this solution no longer works on MacOS >= El Capitan due to System Integrity Protection. (See here)
A possible alternative is to use the folder
/usr/local/bin
that should be accessible.Solution no. 3:
The basic question in the OP seems to not be doable because the newer Mac OSes have “System Integrity Protection” which prevents “unauthorized” changes to key directories such as
/usr/bin
, and sudo
cannot override that.The suggestion of using
/usr/local/bin
and /usr/local/Frameworks
seems like it should work (I haven’t tried it). However, at https://opensource.com/article/19/5/python-3-default-mac
, Matthew Broberg suggests that it is likely to create problems when updating.In that same article, Moshe Zadka recommends using
pyenv
to manage Python environments and using shell aliases rather than symlinks.I was going to go with the
/usr/local
suggestion above, but having found this contraindication, I’m going to try Moshe’s method. I’ll report back here if I hit any snags.Update: I followed the method and I still was getting
pip
not found and which python
and python -V
were not giving me the expected results. Doh! I ran:. ~/.bash_profile
(where I had put the recommended
eval '$(pyenv init -)'
command) and suddenly everything was finding the paths and versions as expected.Hope this helps!
Hp scanner music. You would get python version 2.7 or below being installed by default with macOS, you can check your default python version by following command,
To know the list of python versions available on your macOS, run the below command in terminal,
Mac Os Upgrade Python 3
If you want to set Python 3.8 as the default python version on macOS,
- Install latest version of python using terminal command: $ brew install python
- Now change the default python symlink to the version you just installed.
- Now check the default version again using python --version command
⚡️ This should work on Big Sur, Mojave, High Sierra e.t.c
Comments:
- I am using macOS Big Sur and its working for me!
- Hey man! this was useful information.bigMac 02 Sep 2020 11:12:25 GMT
More Posts related to macOS,
More Posts: - Force android app to run in Landscape mode programatically - Android
- Type R is already defined error : Android Error - Android
- Call PHP function on Button click using jquery ajax - PHP
- Can't Run SDK Manager find_java.bat issue - Android
- 10 FTP SFTP Clients and Alternatives - FTP
- auth_client_using_bad_version_title : Error Android Lint - Android
- Delete file using PHP code : unlink() - PHP
- Stop android adb service from command prompt or terminal - Android
- How to add Date and Time to Windows Notepad File - NotepadPlusPlus
- Mac OS X Taking Screen Capture using Terminal - Mac-OS-X
- Create SharePoint Site Collection using PowerShell New-SPSite - SharePoint
- SharePoint workflow Canceled - Coercion Failed: Unable to transform the input lookup data into the requested type - SharePoint
- Android : Prevent App for rotation landscape or portrait - Android
- MySQL 1005 Error : SQLSTATE: HY000 (ER_CANT_CREATE_TABLE) Message: Can't create table '%s' (errno: 150) - MySQL
- How to change Android EditText Cursor Color - Android