2

My Mac came installed with python 2.7 as the default python version. But, this version is no longer supported by many packages and software. I searched several online forums regarding how to change the default python version on mac. But, none of them seem to work. I also installed the latest version of python, and if I type:

python --version

It returns the version as python 3.8. But if I try to install packages like Biopython, I get an error like this -

defaulting to user installation because normal site-packages is not writeable

Collecting biopython Using cached biopython-1.77.tar.gz (16.8 MB)

ERROR: Command errored out with exit status 1:

Biopython requires Python 3.6 or later. Python 2.7 detected

I am really finding it difficult to install many packages required for my work. Any help or suggestions would be greatly appreciated.

Thank you.

manojmw
  • 21
  • 2
  • How exactly are you attempting to install it? – tripleee Nov 30 '20 at 06:50
  • Hello, I am using the following command - pip install biopython. If any changes are to be made, please let me know – manojmw Nov 30 '20 at 07:47
  • Whichever `pip` you are running apparently belongs to Python 2.7. Does it help if you use `pip3`? Or the full path to your 3.8 `pip`? Or the full path to Python 3.8 followed by `-m pip`? – tripleee Nov 30 '20 at 08:00
  • Hello, I tried using **pip3 install biopython**, and biopython was installed. But, if I try to run a simple script, I am getting this error : [ImportError: No module named Bio] – manojmw Nov 30 '20 at 08:26
  • We really need to see more details about where each version of Python is installed, what your `sys.path` looks like, and where the modules are installed. All of this should be easy to find from numerous duplicates. – tripleee Nov 30 '20 at 08:35
  • Thank you so much @tripleee. The error was with the command. I used to type [python script.py] and it was throwing this error - [ImportError: No module named Bio]. But, when I executed this command - [python3 script.py], biopython worked. Now, biopython works for me. – manojmw Nov 30 '20 at 08:45
  • Does this answer your question? [Switch between python 2.7 and python 3.5 on Mac OS X](https://stackoverflow.com/questions/34680228/switch-between-python-2-7-and-python-3-5-on-mac-os-x) – tripleee Nov 30 '20 at 08:50
  • Hello, I have already tried the method mentioned in the link provided by you [Switch between python 2.7 and python 3.5 on Mac OS X]...I am using Mac OS BigSur and it did not work for me. Thank you. – manojmw Nov 30 '20 at 09:44

1 Answers1

1

Probably, you just have to change your Python symbolic link.

Please check this, and you will get it: https://dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf

Renato Aranha
  • 300
  • 1
  • 10
  • Hello, I have already tried the method suggested by you and that is the reason why I am getting python 3.8, when I type the following command (python --version). But, when I try to install Biopython using (pip install biopython) - I am getting the above error and biopython throws an error saying that my 'default version of python is 2.7'. – manojmw Nov 30 '20 at 07:47
  • that's because your pip is also a symbolic link to your python 2.7 instalation. Try "pip3 install biopython" and it will work. Also, to make your pip command point to pip3, please follow this link: https://stackoverflow.com/questions/44455001/how-to-change-pip3-command-to-be-pip – Renato Aranha Dec 01 '20 at 04:44
  • 1
    Thank you for the response. @tripleee suggested the same solution before and I executed it and Biopython was successfully installed....Cheers:) – manojmw Dec 01 '20 at 11:42