Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Xcode permission denied

I have tried to use Python in Xcode, I set everything up according to a tutorial but a big problem showed up after trying to execute the python program.


The issue was, according to Xcode, a lack of permission,


/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'File.py': [Errno 1] Operation not permitted


Program ended with exit code: 2


I'm not informed about permission system of MacOS, I have tried a few things giving Xcode permission through Safety and Privacy but, at least in my case, didn't cause any change.


If somebody has an idea how to fix this issue I'd be happy to hear them.

MacBook Pro 15", macOS 10.15

Posted on Mar 26, 2020 3:50 PM

Reply
11 replies

Mar 26, 2020 4:14 PM in response to zebsy

zebsy wrote:

If somebody has an idea how to fix this issue I'd be happy to hear them.

What issue? You haven't said what you were trying to do.


However, I can virtually guarantee that your tutorial is not going to work. The Python installed on macOS is for Apple's use only. It won't work for anything except basic scripts.


You will have to install your own version of Python. That may mean learning a lot about Python in a hurry.

Mar 27, 2020 12:52 AM in response to etresoft

I already have pycharm, visual code, processing3, and the idle python runner all of needed python, so I thought I already had about 20 python version on my Mac.

I know that processing3 uses Jython to execute python scripts but idle and pycharm both needed me to install the "real" python.

Can't I use their version of python?


But I can try to install python with brew and see how this would go.

Mar 27, 2020 5:49 AM in response to zebsy

You will have to take that up with the developer of the app that isn’t working. Python is a beast unique unto itself. You aren’t likely to find many Mac people who know anything about it. I’m not sure if anyone really knows.


I have one system that includes a Python-based test suite. I build my own Python to avoid these problems. But the test suite issues constant errors complaining that python2 is deprecated. So, I change my config and install python3 instead. It doesn’t work at all with python3. So you can’t use python2 anymore, but python3 requires python2? I have no clue.

Mar 27, 2020 6:55 AM in response to zebsy

You have thrown a bunch of technology at the Python solution and probably much of it is in conflict. I recommend simplification.


Back in the halcyon days of Xcode 3/4, someone on the internet provided Python templates that they had tested with those versions of Xcode. It always pays to note the date on any web post, or Youtube video, because something that worked a decade ago, probably won't now with contemporary versions of Xcode.


If your goal is to build a non-deprecated GUI application with Python, then start with Python 3.8.2 or later from Python.org — not from a package manager. This dynamic build Python distribution allows one to create standalone Cocoa (or Qt) Python applications using py2app, or other related tools. I suggest that you create a virtual environment (venv), activate it, and install pyobjc or qt into that environment. This does not install those modules into the main Python3 framework. Use Xcode to design any custom GUI that can then be requested via Objc in the Python app.


Apple's injection of a limited Python 3.7 distribution with Xcode 11 further complicates matters as it installs Python3 in /usr/bin, and depending how your PATH is configured, you could be using the older Python which as the saying goes, "that dog won't hunt."


I use Sublime Text 3, Sublime Merge, and idle3 in the process of hand coding visual Python solutions. Never even considered PyCharm, or any other commercial Python IDE, free or fee.

Mar 27, 2020 7:08 AM in response to VikingOSX

You're wright.

I shouldn't mix things which aren't supposed to be together.

As in my defence I want to say that I though that maybe through a miracle I would be able to install turtle, I have tried a few times to install it but every time there comes an error, we're supposed to draw komplex geometric forms in school and our informatics teacher told us to use turtle and now I'm stranded on wide ice.

Normally I would use visual code, and if it's too stupid I have to turn back to idle, pygame is a big issue with vscode.

In terminal I would type python3 -m pip install turtle and...


ERROR: Command errored out with exit status 1:

command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7s/966gy_f56zd246hy9jwyrz4h0000gn/T/pip-install-e4yb3rek/turtle/setup.py'"'"'; __file__='"'"'/private/var/folders/7s/966gy_f56zd246hy9jwyrz4h0000gn/T/pip-install-e4yb3rek/turtle/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/7s/966gy_f56zd246hy9jwyrz4h0000gn/T/pip-install-e4yb3rek/turtle/pip-egg-info

cwd: /private/var/folders/7s/966gy_f56zd246hy9jwyrz4h0000gn/T/pip-install-e4yb3rek/turtle/

Complete output (6 lines):

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/private/var/folders/7s/966gy_f56zd246hy9jwyrz4h0000gn/T/pip-install-e4yb3rek/turtle/setup.py", line 40

except ValueError, ve:

^

SyntaxError: invalid syntax

----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


comes out.

I'm a bit aimless how I should work around this error.

Mar 27, 2020 7:36 AM in response to zebsy

zebsy wrote:

I'm a bit aimless how I should work around this error.

That’s what I keep trying to tell you. You can’t work around that error. No part of the system Python(s) can be modified. A few people have tried some custom, local-environment setups so they can run with the system Python. Sometimes those work, sometimes they don’t. But you would need to be a veritable god of macOS, Python, the command line, and patience to get that running.

Mar 27, 2020 9:37 AM in response to zebsy

First of all, turtle is already included in Python.org's Python 3.8.2 build. No need to install it. Apple did not include idle3 or pip3 in their Xcode 11 version of Python3.


See this Python 3.8.2 documentation page on using the built-in turtle graphics.


Python 3.8.2 is installed in /Library/Frameworks/Python.framework, and its binaries (e.g. python3, pip3, idle3, etc. ) are soft-linked back to /usr/local/bin, hence my earlier comment about having your PATH sorted, so you do not access the Xcode Python3 in /usr/bin.


Python 3.8.2 installation also adds a PATH adjustment in your ~/.bash_profile, but I do not believe it does so with the Zsh dot files. You may need to add that PATH tweak to the ~/.zshrc, and ~/.zprofile files.

Apr 4, 2020 1:19 PM in response to zebsy

I had the same problem as you, but I was able to fix it by using the version installed by brew in "/usr/local/bin/python3" instead of the system one. I set that file as the executable for my scheme in Xcode by right clicking it and selecting Quick View (Xcode by default shouldn't let you select it since it's an alias and not the real executable).


This should work even if the system is still using the included python installation as the default one (can be checked using which python3).

Xcode permission denied

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.