0

Python 2.7 is no longer available on Mac Catalina, but I need it to be my default python to get Cocos Creator to build iOS apps correctly. I tried installing Python, and setting the alias as follows, but while typing python correctly runs python 2.7 on the terminal, it reverts to python 3.8.5 the moment I close the terminal (and Cocos still doesnt build correctly). My python 3 is installed using anaconda

Is there a way to make python 2.7 default on Catalina?

https://stackoverflow.com/questions/49704364/make-python3-as-my-default-python-on-mac
Open Terminal
cd
nano ~/.bashrc
alias python=python2 (Add this line on top of .bashrc file)
Press ctr+o (To save the file)
Press Enter
Press ctr+x (To exit the file)
source ~/.bashrc OR . ~/.bashrc (To refresh the bashrc file)
Dan Tang
  • 1,273
  • 2
  • 20
  • 35
  • I think general best practice is not to mess with the OS X-supplied Python installation, but to install your preferred version in parallel. – jarmod Mar 31 '21 at 14:38
  • Don't modify default system Python. Use a virtualenv to build your project code – OneCricketeer Mar 31 '21 at 14:39
  • According to this comment, Python seems to have been removed for Javascript https://github.com/cocos-creator/engine/issues/4608#issuecomment-701112851 – OneCricketeer Mar 31 '21 at 14:42
  • @OneCricketeer Unfortunately that's only for Cocos 3.0, which is leading edge, and Cocos 2.x are all still relying on Python 2.7. – Dan Tang Mar 31 '21 at 14:45
  • I created a virtualenv in python 2.7, but it is still relying on python 3. So I figured, maybe I could change the default python to force it to use 2.7 – Dan Tang Mar 31 '21 at 14:46
  • Is there something in the experimental version that doesn't work for building your apps? I can't speak for cocos, but if you created the environment from your conda/Python3 installation, it wouldn't be a Python2 executable... Generally, I use pyenv to manage all Python versions. I also saw mentioned in the github issues that cocos should have an embedded Python that it uses rather than the system one – OneCricketeer Mar 31 '21 at 14:50
  • Yeah, cocos 3.0 is a major change as they changed the whole interface to support 3D, and our team prefers not to migrate so soon unless absolutely necessary. I guess I will try to mess around more and see if I can get python 2.7 to work – Dan Tang Mar 31 '21 at 14:54
  • Are you sure python 2.7 is not available on Catalina ? Even on Big Sur, `/usr/bin/python -V` gives `2.7.16` – Philippe Mar 31 '21 at 17:20
  • Hmm, I think it's more that the default python is set to python 3 and not 2 from catalina onwards, which is affecting the build process of the game engine i'm using. – Dan Tang Apr 01 '21 at 01:17

0 Answers0