简体   繁体   中英

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.
I then downloaded the latest python which is 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.
How can I make it so it recognizes version 3.8.5 or any version above 3.6?

Symlink python to python3 in /usr/bin . If you ever need to access python 2.7 run 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. This will make maintaining package installs, versions and updates a lot simpler.

References:

Brew: https://brew.sh

For your terminal to run python 3.x run

python3 <your command>

and similarly for 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

pip install biopython

So what you have to ensure is that your pip uses Python 3+ like here

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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