Mac升级Monterey后,Cocos 2.4.x无法构建原生平台

问题:

Mac升级Monterey后,Cocos 2.4.x无法构建原生平台,构建时报错:

Build Failed: Error: Can't find python, please install python or check your environment

原因:

Mac原本自带2.7版本的python,但是升级Monterey后,系统删除了python2,默认自带python3,但是Cocos构建只支持python2,所以报错

解决:

打开终端,按以下指令操作:
1.安装pyenv命名

brew install pyenv

2.配置pyenv初始化指令

//如果没有.zprofile文件,则先创建一个
touch ~/.zprofile

open -e  ~/.zprofile

在文件中插入以下指令

eval "$(pyenv init --path)"
eval "$(pyenv init -)"

3.终端中查看可安装python版本

pyenv install --list

4.安装Python2

pyenv install 2.7.18

5.替换全局的Python版本

pyenv global 2.7.18

6.终端输入:

open ~/.bash_profile

将以下内容添加到bash_profile中:

export PATH="$(pyenv root)/shims:${PATH}"

保存后,终端输入:

source ~/.bash_profile

输入:

open ~/.zshrc

将source ~/.bash_profile添加到zshrc文件中,保存后,终端输入:

source ~/.zshrc

7.输入python,查看显示的python版本:

***@***-MBP ~ % python
Python 2.7.18 (default, Mar 23 2023, 14:50:58) 
[GCC Apple LLVM 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

8.打开Cocos,点击构建,运行成功

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容