Error when running a python3 Xcode project (Too many levels of symbolic links and Operation not permitted) - macOS BigSur

Viewed 1891

I recently bought a new computer (I am completely new with macOS):

  • MacBook Pro (13-inch, M1, 2020)
  • Puce Apple M1
  • macOS Big Sur version 11.1

I would like to set-up a python3 development environment in Xcode.

I followed the following tutorial on the web.

I set up the project interpreter to Python3.

However, when I click on the play button (run), I get an error:

2021-01-09 12:17:40.062440+0100 python3[1139:27278] Failed to open macho file at /Applications/Xcode.app/Contents/Developer/usr/bin/python3 for reading: Too many levels of symbolic links

/Applications/Xcode.app/Contents/Developer/usr/bin/python3: can't open file 'PythonTest.py': [Errno 1] Operation not permitted

Program ended with exit code: 2

I also tried to execute python3 code in the cmd, its working well. So the problem seems to come from Xcode.

Moreover, I observed in my Xcode project that I can select among three propositions:

  • apple Silicon
  • apple Silicon (arm64)
  • apple Rosetta

What is the difference among them (in terms of python execution) ? Knowing that the error appears for each of the previous options.

Thanks for your help.

1 Answers

In my case I had to modify the path of the python bin. Go to Edit Scheme set the Executable to

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python

The best step by step description I found on how to setup a python project in Xcode was here (in chinese): https://blog.csdn.net/qq_15289761/article/details/107082908

Related