Problems with installing Python3 and SQLite on Mac

Source: Internet
Author: User
Tags sqlite

It is recommended to install Python3 on Mac do not use source code to compile and install, but to use

Brew Install Python3 for installation

In addition to creating the required environment after installation, specify the new Python environment as follows:

Virtualenv-p/usr/local/cellar/python3/3.6.2/bin/python3--no-site-packages Obpy17




Mac OSX correctly installs both Python 2.7 and Python3




Mac OSX correctly installs both Python 2.7 and Python3 (this is the original)



About 6 MINUTES to Read/11/29/2015/candy tsai/0 COMMENTS

Python3 out (actually has been out for a long time, dizzy)!

However, many libraries still use Python2.7, so how do you install the two versions on your Mac and differentiate it from the python used by the system? Today's writing is how to properly install the first time, and switch the preset version, not the misuse of the system python.

It's just a few steps, it's not too difficult (maybe you've already installed it)

Step 1 Install Xcode

Step 2 Installation Kit management tool Homebrew

Step 3 Install Python

Step 4 Set Path $path (no fight with system Python)

Step 5 Complete! Confirm Installation Results ~

Step 1 Install Xcode

You can search for Xcode in the App Store and install it and then turn Xcode on-the first time you open it, you'll need to agree to his license agreement and stuff. Then go to the terminal input to install the Xcode command line tool:


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-e821671498019cac.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

1

Xcode-select--install

Install Xcode to the end of this, go to the next step!

Step 2 Installation Kit management tool: Homebrew

Can be posted on the website or in the terminal:


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-266484905d201431.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

1

Ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installation, you can run.

1

Brewdoctor

If it appears

Your system is ready to brew.

On behalf of all OK, if there is warning, also do not worry too much, you can follow the steps to fix it!

If there is a warning, though will see a sentence above

If everything you use Homebrew for is working fine:please don ' t worry and just ignore them.

However, it is recommended that you put things in place, it will not be the time to forget what they have not set the right thing.

Step 3 Install Python

The next step is to formally install Python!

First, enter

1

Python--version

Oh, my God! Have not started to install Python, the computer is already there?

This is the MAC system to use the python, so it is not usually appropriate to move the better yo!

So now we're going to use homebrew to install the usual can (mess?) ) used by Python.

Search Python with homebrew

1

Brewsearchpython

At this point, you'll see Python and Python3.

Because I have already installed, so next will write (installed). To install Python!

1

Brewinstallpython

This will start the installation.

After loading the input

1

Brewinstallpython3

At the time of installation, Python will be installed in the


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-56fdfd3a83e5a33c.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

/usr/local/cellar

Then take a look at this folder.

1

open/usr/local/cellar/


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-e06e581a82a512ef.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

You can see that the python you are installing appears!

In addition to Python, it is possible to install something else, such as SQLite.

In short, don't worry too much, homebrew will take care of himself.

(because I've packed a lot of miles to pick it up, there's probably not a lot of stuff in your folder)

Step 4 Set Path $path (no fight with system Python)

What is path $path?

Remember when we were loading 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 use of $path!

1

Echo$path

And then you'll see a bunch of things like that.

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Semicolon (:) is the meaning of the separation

So when you enter brew in the terminal,

The system will start to look up from/usr/bin.

If you can't find it in/usr/bin.

Will go down a/bin to search, and so on

Now, let's go back to the folder to see

Brew is actually inside the/usr/local/bin!


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-630e2fdca40e4b8e.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

So the problem now is that the system has a python in the/usr/bin.

Now we have python in/usr/local/cellar.

Who will be turned on when the Python command is played on terminal?

Because the path is sequential , it will first find the system's Python

It's time to solve the problem.

1

Sudoemacs/etc/paths

sudo lets us get admin privileges

Use the Emacs program to edit the path file.

Terminal will ask to enter a password

(That is, you need to enter the password for the normal loading of things) now we need to move the/usr/local/bin to the top. Control + K: Cut a line of words control + y: Paste the Word control + x + S: Archive control + x + C: Turn off Emacs


650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-0bd4241de1b75c1a.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

650) this.width=650; "Src=" Http://upload-images.jianshu.io/upload_images/1859396-214e6fa712fb5233.png?imageMogr2 /auto-orient/strip%7cimageview2/2/w/1240 "alt=" 1240 "/>

At this point, one more call.

1

Echo$path

Why hasn't it changed!?

Because to open a new terminal will be updated Yo!

Open a new window and enter it again to see the results we just modified.

Step 5 Complete! Confirm Installation Results ~

This is done!

Actually, Python3 is not going to fight with anyone else.

Because he's an independent python3.

So our main reason is to make sure we read our brew-loaded python.

1

Whichpython

See

/usr/local/bin/python

Let's take a look at Python3.

1

Whichpython3

It should be.

/usr/local/bin/python3

The representative reads the Python just loaded!

Of course if you're going to run the system itself python

(should not be able to use ~)

Just enter

1

/usr/bin/python

In short, it is ... It's done!

Original address: https://stringpiggy.hpd.io/mac-osx-python3-dual-install/#step2



A soup 8 yi
Links: http://www.jianshu.com/p/51811fa24752/
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.


Problems with installing Python3 and SQLite on Mac

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.