I am very new to the python and MAC world, we are currently running into an issue with updating the product under usr/bin/python directory. By only updating the python 3 product does not update under this directory. By any chance you could give me some direction of resolving the updating issue? Thanks
Its not really clear from the limited information above what you want to do, nor what you’ve actually tried, nor what OS or Python version you are on (as this differs greatly between different recent macOS versions).
In general, you should avoid touching the system Python (
/usr/bin/pythonX), and install your own copy (via Python.org, Homebrew, Anaconda, etc). Also, note, unless they changed it in the latest macOS versions,
usr/bin/python still points to the EoL, unsupported Python 2, while
usr/bin/python3 is Python 3 (on recent-enough macOS).
While some parts are out of date, I suggest reading the official tutorial, which describes how to obtain a recent Python version and general recommendations for using Python on macOS. Then, download either the latest official Python.org Python, Python via homebrew (
brew install python3), or Anaconda Python, and going from there.
Best of luck!
/usr/bin/python3 are system binaries that cannot be changed by users.
/user/bin/python is python2,
/usr/bin/python3 is an alias for the Python 3 installation in Xcode or the Xcode Command Line Tools.
Other installations of Python, such as the python.org installer and homebrew, cannot change the binaries in
/usr/bin/. You’ll have to adjust your shell’s PATH to use the installation that you intend to use.
I’m not a expert on MacOS but I will share the approach I’ve used for years when using Python. Keep the system Python separate from the Python you use for main development work. If what you are doing is simple scripting and you don’t need things outside the standard library, you can use the system Python. Otherwise, don’t use it and don’t mess with it.
Install your “dev” Python into /usr/local/python-x.y.z or a similar location. Setup your shell (e.g. path variable and aliases) so that “python” and “python3” will run your preferred version. In scripts, use
#!/usr/bin/python3 to run with system Python. Use
#!/usr/bin/env python3 to run with your dev version.
Trying to stick with the system Python for dev work leads to sadness, in my experience. It is inevitably out-of-date. Building Python from source code is not hard.
thanks for your reply. we are on MAC osx 11.6.2. we installed python just with regular way. I have no diea where this /usr/bin/python3 from. currently we have been asked to update python to the latest version, but by installing the newest version python is not updating /usr/bin/python3…so I am very confused, how to update it
thanks Ronald, I have tried to update our xcode and xcode command line tools to the latest version…still no luck, it didnt touch /usr/bin/python3…
Could you explain what you mean by “we installed Python the regular way”? There are many ways install Python on macOS, many of them quite popular: Xcode, Python.org, Homebrew, Anaconda, Fink/MacPorts, etc. Please state specifically which one of these you mean.
In any case, to summarize what Ronald, Niel and myself have explained previously:
Your macOS version has a build-in stub for system-level Python at
/usr/bin/python3, which gets installed by Apple’s Xcode developer tools.
Any updates to this binary is the responsibility of Apple and its Xcode developer tools. If it is not updated, unless your install is broken, its likely that the latest version simply not available from Apple for your OS.
In general, all of us as well as the official tutorial I linked recommend you do not use this Python, and more importantly do not try to replace, update, remove or delete it yourself, and instead install your own copy instead via any of the ways we mentioned/linked
There are several ways to ensure your own Python is invoked when you type
python3from a user terminal, or run a Python script. The above comments and the official tutorial explain how to do just that.
Best of luck!