MAC OSX is correctly installed with PYTHON 2.7 and PYTHON3
Python3 has come out (it has been out for a long time, dizzy)!
But there are still many libraries that use Python2.7, so how do you install the two versions in your Mac and separate them from the Python area used by the system? Today's writing is how to properly install it for the first time, and switch to the preset version, not the wrong Python for the system.
It's just a couple of steps, and it's not going to be too hard (or maybe you're just going to have it installed)
STEP 1 Installation XCODE
You can search for Xcode and install it in the APP Store
After the installation, open Xcode.
The first time you open it, you'll need to agree with his License agreement.
Then go to terminal and install the Xcode command line tool:
Install Xcode to the end of this, to enter the next step!
STEP 2 Installation Kit management tool: HOMEBREW
You can go to the official website or paste it in terminal:
|
Ruby -e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)" |
You can run after the installation.
If the
Your system is ready to brew.
On behalf of everything OK, if there is Warning, also don't worry too much, you can follow the steps to fix it!
If there is a Warning, though you will see a sentence
If everything you use Homebrew for is working fine:please don ' t worry and just ignore them.
But it is also suggested that you install things well, and that it is not time to forget what you really are.
STEP 3 Installation PYTHON
Next step is to formally enter the installation of Python!
First, enter
Oh, my God! has not yet started Python, how has the computer been there?
This is the Python that the MAC system uses, so it's not always good to be chaotic!
So now we're going to use homebrew to install the usual. ) used by Python.
Search Python with Homebrew
At this point, you'll see Python and Python3.
Because I have already installed, so the side will write (installed).
To install Python!
This is the beginning of the installation.
After the installation, enter
When installed, Python will be installed in
/usr/local/cellar
Then look at this folder (or shift+command+g input path)
You can see that the Python you are installing is now out there!
In addition to Python, it is possible to install something else, such as SQLite.
Always, don't worry too much, homebrew will take care of himself.
(Because I'm a lot of miles copied copied, so you might not have so much in your folders)
STEP 4 Set Path $PATH (no fight with the system PYTHON)
What is the path $PATH?
Remember when we were in Python, we entered Brew,
The system will automatically know to start running homebrew.
How does the system know where our brew is?
This is the purpose of $PATH!
Then you'll see a bunch of things like this.
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Score (:) is the meaning of separation
So when you enter brew in terminal,
The system will start looking for/usr/bin.
If you can't find it in/usr/bin,
Will go down a/bin to search, and push
Now, we go back to the folder to see
Brew is actually in the/usr/local/bin!
So the question now is that the system has a Python in/usr/bin.
Now we have Python in/usr/local/cellar.
So who's going to be open when terminal a python command?
Because the path is sequential, it will first find the system Python
Now we're going to solve this problem.
sudo allows us to get admin privileges
Edit the path file with the Emacs program
Terminal will ask to enter the password
(That is, the password that you need to enter in your normal installation)
Now we're going to move the/usr/local/bin to the top.
Control + K: Cut a line of words
Control + y: Put the words on the stickers
Control + x + S: Archive
CONTROL + x + C: get rid of Emacs
This time, one more call.
Why hasn't it changed!?
Because to open a new terminal will update Yo!
Open the new window and enter it again and you'll see the results we just modified.
STEP 5 Complete! Confirm the installation Results ~
This is done!
Actually, Python3 is not going to fight with the others.
Because he is the python3 of independence.
So we're mainly trying to make sure that we read our brew python
At this time to see
/usr/local/bin/python
Let's take a look at Python3.
should be
/usr/local/bin/python3
The representative read the python that was just installed!
Of course if you're going to run the system itself python
(should not be used to ~)
Just enter
The thing is ... It's done!
Reprinted from Https://stringpiggy.hpd.io/mac-osx-python3-dual-install/
MAC uses kit management tool homebrew to install python2.7 and Python3 correctly at the same time