简体   繁体   English

在 Mac 上更新 python 版本

[英]Updating python version on a Mac

I just bought a MacBook Pro and the preinstalled version of python is 2.7.x and I was attempting to install biopython but that requires python 3.6 and higher.我刚买了一台 MacBook Pro,预装的 python 版本是 2.7.x,我试图安装biopython但这需要 python 3.6 及更高版本。
I then downloaded the latest python which is 3.8.5.然后我下载了最新的python 3.8.5。
When I run terminal to install biopython I get an error saying that biopython requires version above 3.6 to run and that version 2.7 is downloaded.当我运行终端来安装biopython我收到一条错误消息,提示biopython需要 3.6 以上的版本才能运行,并且下载了 2.7 版本。
How can I make it so it recognizes version 3.8.5 or any version above 3.6?我怎样才能让它识别版本 3.8.5 或任何高于 3.6 的版本?

Symlink python to python3 in /usr/bin ./usr/bin中将 python 符号链接到 python3。 If you ever need to access python 2.7 run python2.7.如果您需要访问 python 2.7,请运行 python2.7。

brew install python3
brew link
sudo mv /usr/bin/python /usr/bin/python2.7 # skip this step if /usr/bin/python2.7 already exists
ln -s /usr/local/bin/python $(which python3) # note /usr/local/bin instead of /usr/bin

Note:笔记:

Use brew (ubiquitous open source MacOS package manager) to install python3.使用brew (无处不在的开源MacOS包管理器)安装python3。 This will make maintaining package installs, versions and updates a lot simpler.这将使维护软件包安装、版本和更新变得更加简单。

References:参考:

Brew: https://brew.sh酿造: https : //brew.sh

For your terminal to run python 3.x run让你的终端运行 python 3.x run

python3 <your command>

and similarly for pip和 pip 类似

pip3 install <package name> 

Or you can just make a virtual environment.或者你可以创建一个虚拟环境。 Ref here .参考这里

I've checked docs for biopython https://biopython.org/wiki/Download and they ask you to run我已经检查了 biopython https://biopython.org/wiki/Download 的文档,他们要求您运行

pip install biopython

So what you have to ensure is that your pip uses Python 3+ like here所以你必须确保你的pip像这里一样使用 Python 3+

> pip -V
pip 20.2.2 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM