Detailed introduction on how to switch between multiple versions of Python on Mac

黄舟
Release: 2017-06-18 11:11:49
Original
2574 people have browsed it

Mac comes with thePython2.x version. Sometimes you need to use the Python3.x version for development, but you cannot delete Python2.x, which may cause system instability. , then you need toinstallMultiple versions of Python. This article will introduce to you how to switch between multiple versions of Python on Mac. Friends who need it can take a look.

It comes with Mac For the Python2.x version, sometimes you need to use the Python3.x version for development, but you cannot delete Python2.x, which may cause system instability, so you need to install multiple versions of Python.

1. Install Python 3.x version, I installed 3.6.1;

2. Open the terminal and enter: sudo vi ~/.bashrc;

3. Enter and save at the top of the pop-up editing page:


alias python2='/Library/Frameworks/Python.framework/Versions/2.x/bin/python2.x' alias python3='/Library/Frameworks/Python.framework/Versions/3.x/bin/python3.x'
Copy after login

I have Python2.7 and Python3.6 versions on my machine. Please replace the x above according to the situation.

4. Restart the terminal (terminal) or enter: source ~/.bashrc

5. Verify, enter python2 in the terminal (terminal) to represent the Python2.x version, enter python3 Represents the Python3.x version.

The above is the detailed content of Detailed introduction on how to switch between multiple versions of Python on Mac. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!