iOS 进阶开发工作生活

Python 2.7 辛苦了,你好Python 3.7

2019-06-29  本文已影响52人  Cooci_和谐学习_不急不躁

Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
很多小伙伴在使用python的时候,都会报出相应警告,毕竟2020.我们的可爱敬业的 Python 2.7就会退出我们的舞台,辛苦了。不断的更新也是不断功能的健全和完美!今天也替换了 python 3.7.3 体验还不错,暂时没有任何问题,文档记录

image.png

安装python3

直接下载安装

web界面是真的丑

terminal里运行open ~/.bash_profile,打开~/.bash_profile,直接修改文件即可

open  ~/.bash_profile
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

或者:

source ~/.bash_profile
# Setting PATH for Python 3.7

# The original version is saved in .bash_profile.pysave

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.7/bin:

alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

Python 2.7与Python 3.7版本的切换

使用Python 2.7时,直接将~/.bash_profile文件中3.7的版本注释掉,即

#aliaspython="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

使用Python 3.7时,直接将~/.bash_profile文件中3.7的版本打开,即

aliaspython="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

安装Homebrew

image.png

Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。
一句话总结 : 用它超爽

要求

安装和卸载

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ cd `brew --prefix`
$ rm -rf Cellar
$ brew prune
$ rm `git ls-files`
$ rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
$ rm -rf .git
$ rm -rf ~/Library/Caches/Homebrew

Homebrew基本使用

brew install <packageName>
比如:安装node
$ brew install node
$ brew uninstall <packageName>
比如:卸载node
$ brew uninstall node
$ brew search <packageName>
* 查看已安装包列表
$ brew list
* 查看任意包信息
$ brew info <packageName>
* 更新Homebrew
$ brew update
* 查看Homebrew版本
$ brew -v
* Homebrew帮助信息
$ brew -h

安装python

* 1、查看自己的python版本
python
* 2、查看python3的安装包
brew search python3
* 3、安装python3
brew install python3
接下来需要等待几分钟,速度有点慢,抽根烟,45度仰望一下天空
image.png

OK,可以看到python3的实际安装目录是/usr/local/Cellar/python/3.7.3

因为每次都需要python3 感觉有点恶心,于是重命名python

open ~/.bash_profile
alias python="/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/bin/python3.7"
source ~/.bash_profile
python

python的作用 - iOS开发可以自己模拟一个Python服务器

控制台:
sudo easy_install pip 安装pip(python的包管理工具)
sudo pip instlal flask 安装flask框架(python的web框架)
pip list

image.png image.png image.png image.png image.png image.png image.png image.png
上一篇 下一篇

猜你喜欢

热点阅读